Hi,
I want to write a function which is almost the same as var_dump(). Here is what I want to do. I want to print out all the values of an array, in the way var_dump does it. That works fine for me, until I use multi-dimensional arrays. When I have a multi-dimensional array I'd like to have my output indented en that's my problem.
This is my function:
<?
function dumparr($arr){
if(is_array($arr)){
$elements = count($arr);
echo "Array[$elements] {<br><br>";
for($i=0;$i<$elements;$i++){
if(is_array($arr[$i])){
dumparr($arr[$i]);
} else {
echo " [$i] => " . htmlentities($arr[$i]) . "<br><br>";
}
}
echo "}<br><br>";
} else {
echo "not an array<br><br>";
}
}
?>
and this is my test array:
<?
$an_array = array(
array("this", "is", "a"),
array("multi", "-", "dimensional"),
array("array", ".", "the"),
array("output", "is", "wrong"));
dumparr($an_array);
?>
I'd be very thankfull for those who help me out!
Greetz