function print_names($node, $depth = 0) { echo str_repeat(" ", $depth) . $node->name . "\n"; foreach ($node->children as $child) { print_names($child, $depth + 1); } }
<?php $users = array("first_name" => "Michael", "last_name" => "Choi"); function print_names($array) { echo 'There are ' . count($array) . ' keys in this array: first_name, last_name <br>'; foreach ($array as $key => $value) { echo 'The value in the key ' . $key . ' is ' . $value . '. <br>'; } echo '<br>'; } print_names($users);