Php

PHP recursively trim multidimesional arrays

/**
      * Function recursivly trim all array elements
      * @param type $data
      * @return type
      */
     function trimArray($data)
     {
         if (($data == null)||(is_object($data)))
         {
             return null;
         }
         if (is_array($data))
         {
             return array_map([$this,'trimArray'] , $data);
         }
         return trim($data);
     }

Similar Posts