<?php
$flat_list = $tree = array();
$tree = array(
"one",
array(
"two",
"three",
array(
"four"
),
"five"
),
"six",
"seven",
array(
"eight"
)
);
function descend($into) {
global $flat_list;
if (is_array($into)) {
foreach($into as $item) {
descend($item);
}
} else {
$flat_list[] = $into;
}
}
descend($tree);
print_r($tree);
echo "\r\n";
print_r($flat_list);
?>