note 99765 added to function.var-dump

From: Date: Fri, 03 Sep 2010 19:56:24 +0000
Subject: note 99765 added to function.var-dump
Groups: php.notes 
Request: Send a blank email to php-notes+get-172309@lists.php.net to get a copy of this message
I made this recursive version of var_dump to show array values into a HTML table. <?php #Recursive Funcition function dump_table($var, $title=false, $level=0) { if($level==0) { echo '<table width="400" border="0" cellspacing="1" cellpadding="3" class="dump">'; if($title) echo '<tr> <th align="center" colspan="2">'.$title.'</th> </tr>'; echo ' <tr> <th align="right">VAR NAME</th> <th align="left">VALUE</th> </tr>'; } else { echo '<tr> <td colspan="2"> <table width="100%" border="0" cellspacing="3" cellpadding="3" class="dump_b"> </td> </tr>'; } foreach($var as $i=>$value) { if(is_array($value) or is_object($value)) { dump_table($value, false, ($level +1)); } else { echo '<tr> <td align="right" width="50%" >'.$i.'</th> <td align="left" width="50%" >'.$value.'</th> </tr>'; } } echo '</table>'; } #### HOW TO USE $libertadores[0]='Palmeiras'; $libertadores[1]='Sao Paulo'; $libertadores[2]='Santos'; dump_table($libertadores, 'Libertadores - Brazilian Champions'); ?> CSS Styles: http://andresa.net/exemplos/dump_table.css PHP LIVE DEMO: http://andresa.net/exemplos/dump_table.php ---- Server IP: 187.16.23.128 Probable Submitter: 189.29.36.184 ---- Manual Page -- http://www.php.net/manual/en/function.var-dump.php Edit -- https://master.php.net/note/edit/99765 Del: integrated -- https://master.php.net/note/delete/99765/integrated Del: useless -- https://master.php.net/note/delete/99765/useless Del: bad code -- https://master.php.net/note/delete/99765/bad+code Del: spam -- https://master.php.net/note/delete/99765/spam Del: non-english -- https://master.php.net/note/delete/99765/non-english Del: in docs -- https://master.php.net/note/delete/99765/in+docs Del: other reasons-- https://master.php.net/note/delete/99765 Reject -- https://master.php.net/note/reject/99765 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172309) next »