Feature #2883: improve t3lib_div::trimExplode()
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 5 Sep 2007 07:42:24 +0000 (07:42 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Wed, 5 Sep 2007 07:42:24 +0000 (07:42 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2487 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php

index e96f941..643476d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+
+2007-09-05  Martin Kutschker  <martin.t.kutschker@blackbox.net>
+
+       * Feature #2883: improve t3lib_div::trimExplode()
+
 2007-09-05  Dmitry Dulepov  <dmitry@typo3.org>
 
        * Added Georgian language to TYPO3
index c5c19dd..7453989 100755 (executable)
@@ -1451,15 +1451,21 @@ class t3lib_div {
         * @return      array           Exploded values
         */
        function trimExplode($delim, $string, $onlyNonEmptyValues=0)    {
-               $temp = explode($delim,$string);
-               $newtemp=array();
-               while(list($key,$val)=each($temp))      {
-                       if (!$onlyNonEmptyValues || strcmp('',trim($val)))      {
-                               $newtemp[]=trim($val);
+               $array = explode($delim, $string);
+               if ($onlyNonEmptyValues) {
+                       foreach($array as $index => &$value) {
+                               $value = trim($value);
+                               if ($value == '') {
+                                       unset($array[$index]);
+                               }
+                       }
+                       $array = array_merge($array);
+               } else {
+                       foreach($array as $key => &$value) {
+                               $value = trim($value);
                        }
                }
-               reset($newtemp);
-               return $newtemp;
+               return $array;
        }
 
        /**