[TYPO3-core] RFC: Feature #2883 / t3lib_div::trimExplode

Martin Kutschker martin.kutschker-n0spam at no5pam-blackbox.net
Mon Jul 16 22:50:04 CEST 2007


Wolfgang Klinger schrieb:
> 
> *hiya!*
> 
> Patch request / trunk
> 
> 
> Bugtracker: http://bugs.typo3.org/view.php?id=2883
> 
> I tested it again and measured the difference with XDebug,
> it's still faster and there's no difference in the results
> anymore.
> 
> Please test with the code given in the
> latest comment here: http://bugs.typo3.org/view.php?id=2883

Please add this to the test (requires PHP5):

     function trimExplodeMASI($delim, $string, $onlyNonEmptyValues=0) {
         $array = explode($delim, $string);
         if ($onlyNonEmptyValues) {
             foreach($array as $index => &$value) {
                 $value = trim($value);
                 if ($value == '') {
                     unset($array[$index]);
                 }
             }
             $array = array_merge($array); // reindex array
         } else {
             foreach($array as $key => &$value) {
                 $value = trim($value);
             }
         }
         return $array;
     }

My tests showed that it's a fraction faster :-)

Masi


More information about the TYPO3-team-core mailing list