note 91979 added to function.var-export

From: Date: Fri, 03 Jul 2009 12:21:15 +0000
Subject: note 91979 added to function.var-export
Groups: php.notes 
Request: Send a blank email to php-notes+get-157874@lists.php.net to get a copy of this message
The output can be difficult to decipher when looking at an array with many levels and many elements on each level. For example: <?php print ('$bigarray = ' . var_export($bigarray, true) . "\n"); ?> will return: $bigarray = array( ... (500 lines skipped) ... 'mod' => 'charlie', Whereas the routine below can be called with: <?php recursive_print ('$bigarray', $bigarray); ?> and it will return: $bigarray['firstelement'] = 'something' ... (500 lines skipped) ... $bigarray['foo']['bar']['0']['somethingelse']['mod'] = 'charlie' Here's the function: <?php function recursive_print ($varname, $varval) { if (! is_array($varval)): print $varname . ' = ' . $varval . "<br>\n"; else: foreach ($varval as $key => $val): recursive_print ($varname . "['" . $key . "']", $val); endforeach; endif; } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 67.165.168.203 ---- Manual Page -- http://www.php.net/manual/en/function.var-export.php Edit -- https://master.php.net/note/edit/91979 Del: integrated -- https://master.php.net/note/delete/91979/integrated Del: useless -- https://master.php.net/note/delete/91979/useless Del: bad code -- https://master.php.net/note/delete/91979/bad+code Del: spam -- https://master.php.net/note/delete/91979/spam Del: non-english -- https://master.php.net/note/delete/91979/non-english Del: in docs -- https://master.php.net/note/delete/91979/in+docs Del: other reasons-- https://master.php.net/note/delete/91979 Reject -- https://master.php.net/note/reject/91979 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157874) next »