note 38396 added to ref.array

From: Date: Fri, 19 Dec 2003 07:30:47 +0000
Subject: note 38396 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-62210@lists.php.net to get a copy of this message
A quick and dirty code snippet for dumping simple arrays, arrays of arrays, arrays of arrays of arrays... and so on. <?php function dumparray( $val0 ) { echo "<style>div { font: 8pt 'lucida console'; margin-left: 10px; } </style>"; foreach( $val0 as $key1 => $val1 ) { echo "<div><span style='width:120px; font-weight:bold;'>$key1</span>"; if ( is_array( $val1 ) ) { echo "<div>"; dumparray( $val1 ); echo "</div>\n"; } else { echo "$val1"; } echo "</div>\n"; } } ?> <?php // example $foo[ 0 ] = 'aaa'; $foo[ 1 ][ 'bbb' ] = 'bbb'; $foo[ 1 ][ 'ccc' ] = array( 'ddd', 'eee' ); dumparray( $foo ); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38396 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38396&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38396&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62210) next »