note 34913 added to function.print-r

From: Date: Mon, 11 Aug 2003 18:58:57 +0000
Subject: note 34913 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-53894@lists.php.net to get a copy of this message
Sorry, the previous code wasn't quite perfect (possibly my excitement at writing my first recursive function!). Here's the correct function: (the output is almost the same, but a little bit closer to XHTML compliance) Note that not all values will get <INPUT> tags in the old version! function print_var($var,$prefix = '') { if (is_array($var)) { foreach ($var as $key => $this) { if (is_array($this)) { print_var($this,"$prefix" . "[$key]"); } else { print "$prefix" . "[$key] = $this<BR>\n"; print "<INPUT TYPE=\"hidden\" NAME=\"$prefix" . "[$key]\" VALUE=\"$this\" \>\n"; } } } else { print "$prefix = $var<BR>"; print "<INPUT TYPE=\"hidden\" NAME=\"$prefix\" VALUE=\"$var\" \>\n"; } } The new version has exactly the same usage as the old one. ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34913 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34913&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34913&report=yes

« previous php.notes (#53894) next »