[TYPO3-core] t3lib_div::trimExplode clean up

Martin Kutschker martin.kutschker-n0spam at no5pam-blackbox.net
Mon Sep 10 22:18:28 CEST 2007


Dmitry Dulepov [typo3] schrieb:
> Martin Kutschker wrote:
>> Again deliberately done for maximum performance. We save the 
>> duplication of the array ($arr = $arr) that way.
> 
> You can get rid of last line in the function. And you can remove "else 
> {" and "}" because "if" returns unconditionally. This way it is even 
> smaller but speed is the same.
> 
> function trimExplode($delim, $string, $onlyNonEmptyValues=0)    {
>     $array = explode($delim, $string);
>     if ($onlyNonEmptyValues) {
>         $new_array = array();
>         foreach($array as $index => $value) {
>             $value = trim($value);
>             if ($value != '') {
>                 $new_array[] = $value;
>             }
>         }
>         return $new_array;
>     }
>     foreach($array as $key => &$value) {
>         $value = trim($value);
>     }
>     return $array;
> }

Done.

Masi


More information about the TYPO3-team-core mailing list