Ejemplo n.º 1
0
 /**
  * Will flat an multilevel array
  *
  * Keys are not preserved, and dupliacted values are stored.
  *
  * @param array $array
  *
  * @return array flatten array
  * @access public
  * @static
  */
 public static function flat($array)
 {
     $arr = array();
     foreach ($array as $a) {
         if (is_array($a)) {
             $arr = array_merge($arr, array_values(Arrays::flat($a)));
         } else {
             $arr[] = $a;
         }
     }
     return $arr;
 }
Ejemplo n.º 2
0
 /**
  * Get join aguments into path.
  *
  * Will join all elements, they can be an arrays ({@link Arrays::flat()} is used)
  * or single arguments.
  *
  * @access public
  * @static
  */
 public static function join()
 {
     $argv = Arrays::flat(func_get_args());
     $path = array();
     while (list(, $c) = each($argv)) {
         $c = Path::split($c);
         if (preg_match('#^[a-z]:$#', $c[0])) {
             $path = array();
         }
         $path = array_merge($path, $c);
     }
     return implode(self::DS, $path);
 }