variable probe revision
| From: | Frank Stanovcak | Date: | Mon, 12 Jan 2009 21:11:47 +0000 |
| Subject: | variable probe revision | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-286150@lists.php.net to get a copy of this message | ||
I posted this once before, and then tried to use it multiple times in a
script. As you can guess I got a bunch of func already defined errors.
Here is a revision incase anyone decided to use it that will work multiple
times in the same script for variable watching.
-------Code follows-------
<?php
if(!function_exists(breakarray)){
function breakarray($passed){
echo '<table
border="1"><tr><th>key</th><th>value</th></tr>';
foreach($passed as $tkey=>$tvalue){
echo '<tr><td>[' , $tkey , ']</td><td>';
if(is_array($tvalue)){
if(sizeof($tvalue) > 0){
breakarray($tvalue);
echo '</td></tr>';
}else{
echo '"' , $tvalue , '"</td></tr>';
};
}else{
echo 'EMPTY </td></tr>';
};
};
echo '</table>';
};
};
echo '<table border=1><tr> <th>variable</th> <th>value</th>
</tr>';
foreach(get_defined_vars() as $key => $value){
echo '<tr><td>$',$key ,'</td><td>';
if(is_array($value) and $key != 'GLOBALS'){
if(sizeof($value) > 0){
breakarray($value);
echo '</td></tr>';
}else{
echo 'EMPTY </td></tr>';
};
}else{
echo '"' , $value , '"</td></tr>';
};
};
echo '</table>';
?>