note 34912 added to function.print-r

From: Date: Mon, 11 Aug 2003 18:54:07 +0000
Subject: note 34912 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-53893@lists.php.net to get a copy of this message
I also 'rewrote' the syntax, because I wanted to pass a large mess of multi-dimensional arrays and things over to another page to finally save them after the editor. 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>"; } } // examples print_var($_POST['month'],'month'); print_var($_POST['year'],'year'); print_var($_POST['data'],'data'); This will create a handy debug output which is very compact compared to print_r (example from that follows) and also passes on everything to another script with <INPUT TYPE=hidden> tags. month>8 year>3 data[Zgut] = ZZ data[Stuff and things][0][Bling] = B1 data[Stuff and things][0][Zgut] = Z1 data[Stuff and things][1][Bling] = B2 data[Stuff and things][1][Zgut] = Z2 data[Stuff and things][2][Bling] = B3 data[Stuff and things][2][Zgut] = Z3 data[Stuff and things][3][Bling] = B4 data[Stuff and things][3][Zgut] = Z4 data[Bling!] = BB ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34912 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34912&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34912&report=yes

« previous php.notes (#53893) next »