<?php
function show_php($var,$indent=' ',$niv='0') {
$str='';
if (is_array($var)) {
$str .= "<b>[array][".count($var)."]</b><br />";
foreach ($var as $k=>$v) {
for($i=0;$i<$niv;$i++) {
$str.= $indent;
}
$str.= "$indent<em>\"{$k}\"=></em>";
$str.= show_php($v, $indent, $niv+1);
}
} elseif (is_object($var)) {
$str .= "<b>[objet]-class=[" . get_class($var) . "]-method=[";
$arr = get_class_methods($var);
foreach ($arr as $method) {
$str .= "[function $method()]";
}
$str .= "]-";
$str .= "</b>";
$str .= show_php(get_object_vars($var), $indent, $niv+1);
} else {
$str .= "<em>[" . gettype($var) . "]</em>=[{$var}]<br />";
}
return($str);
}
$tab=array(
"first"=>"firstValue",
"second"=>array(
"first"=>1,
"second"=>2,
"third"=>array(
"first"=>"one",
"second"=>"two"
),
),
);
echo "tab=".show_php($tab);
echo "<hr />";
var_dump($tab);
?>
function show_php($var,$indent=' ',$niv='0') {
$str='';
if (is_array($var)) {
$str .= "<b>[array][".count($var)."]</b><br />";
foreach ($var as $k=>$v) {
for($i=0;$i<$niv;$i++) {
$str.= $indent;
}
$str.= "$indent<em>\"{$k}\"=></em>";
$str.= show_php($v, $indent, $niv+1);
}
} elseif (is_object($var)) {
$str .= "<b>[objet]-class=[" . get_class($var) . "]-method=[";
$arr = get_class_methods($var);
foreach ($arr as $method) {
$str .= "[function $method()]";
}
$str .= "]-";
$str .= "</b>";
$str .= show_php(get_object_vars($var), $indent, $niv+1);
} else {
$str .= "<em>[" . gettype($var) . "]</em>=[{$var}]<br />";
}
return($str);
}
$tab=array(
"first"=>"firstValue",
"second"=>array(
"first"=>1,
"second"=>2,
"third"=>array(
"first"=>"one",
"second"=>"two"
),
),
);
echo "tab=".show_php($tab);
echo "<hr />";
var_dump($tab);
?>
