Display an array
<?php
function array_display($array, $pre=FALSE)
{
$tag = $pre ? 'pre' : 'p';
printf("<%s>%s</%s>\n", $tag, var_export($array, TRUE), $tag);
}
function change(&$element, $key, $mark)
{
$element = "$mark$key$mark, the $element";
}
$dogs = array('A' => 'AA', 'Bud' => 'BB');
array_display($dogs, TRUE);
array_walk($dogs, 'change', '*');
array_display($dogs, TRUE);
?>
Related examples in the same category