本文整理匯總了PHP中Arrays::flat方法的典型用法代碼示例。如果您正苦於以下問題:PHP Arrays::flat方法的具體用法?PHP Arrays::flat怎麽用?PHP Arrays::flat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Arrays
的用法示例。
在下文中一共展示了Arrays::flat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: flat
/**
* 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;
}
示例2: join
/**
* 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);
}