[TYPO3-core] RFC #10511: simplify and speed up t3lib_div::trimExplode()

Ingo Renner ingo at typo3.org
Sat Feb 21 11:38:22 CET 2009


Peter Foerger wrote:
> Hi,
> 
> Ingo Renner schrieb:
> 
>> Problem:
>> currently trimExplode() uses loops to process elements of arrays created
>> by an explode before.
>>
>>
>> Solution:
>> Using native php functions that achieve the same goal is simpler,
>> shorter, and most importantly faster.
>> To make sure the behavior stays as it is right now I created four unit
>> tests.
>>
> 
> GREAT! I haven't tested yet, just read your code.
> 
> Two remarks:
> - will that work in terms of the expected result?:
> t3lib_div::trimExplode(',', $testString, true, 3);
> @see http://bugs.typo3.org/view.php?id=9779

after looking at it I'd say trimExplode's behavior is totally correct by

1) testcase checkTrimExplodeLimitsResults()
2) PHP's manual for explode(): http://php.net/explode
	-> the resulting array is limited to $limit elements, where the last 
element contains the rest of the string that has not been split by 
$delimiter


best
Ingo

-- 
Ingo Renner
TYPO3 Core Developer, Release Manager TYPO3 4.2


More information about the TYPO3-team-core mailing list