note 34913 deleted from function.print-r by aidan

From: Date: Mon, 11 Oct 2004 13:06:38 +0000
Subject: note 34913 deleted from function.print-r by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78337@lists.php.net to get a copy of this message
Note Submitter: tomer at parity-bit dot com ---- 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.

« previous php.notes (#78337) next »