Voting

: max(four, eight)?
(Example: nine)

The Note You're Voting On

Anonymous
21 years ago
<?php
/**
flatten an arbitrarily deep multidimensional array
into a list of its scalar values
(may be inefficient for large structures)
(will infinite recurse on self-referential structures)
(could be extended to handle objects)
*/
function array_values_recursive($ary)
{
$lst = array();
foreach(
array_keys($ary) as $k ){
$v = $ary[$k];
if (
is_scalar($v)) {
$lst[] = $v;
} elseif (
is_array($v)) {
$lst = array_merge( $lst,
array_values_recursive($v)
);
}
}
return
$lst;
}
?>

code till dawn! -mark meves!

<< Back to user notes page

To Top