Re: variable probe revision

From: Date: Mon, 12 Jan 2009 21:40:37 +0000
Subject: Re: variable probe revision
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-286159@lists.php.net to get a copy of this message
On Mon, 2009-01-12 at 16:11 -0500, Frank Stanovcak wrote: > 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>'; > ?> > > > Why not put the function in a functions include and use a require_once() on it? Ash www.ashleysheridan.co.uk

« previous php.general (#286159) next »