note 84117 added to function.print-r

From: Date: Sat, 28 Jun 2008 20:21:52 +0000
Subject: note 84117 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-140900@lists.php.net to get a copy of this message
I have written a nice debugging function. This function handles arrays beautifully. <?php //Debug variables, $i and $k are for recursive use function DebugDisplayVar($input, $name = "Debug", $i = "0", $k = array("Error")){ if(is_array($input)) { foreach ($input as $i => $value){ $temp = $k; $temp[] = $i; DebugDisplayVar($value, $name, $i, $temp);} }else{//if not array echo "$".$name;//[$k] foreach ($k as $i => $value){ if($value !=="Error"){echo "[$value]";} } echo " = $input<br>"; } } //outputs Debug[0] = value Debug[1] = another value ect... ?> ---- Server IP: 64.71.164.2 Probable Submitter: 24.12.45.82 ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit -- https://master.php.net/note/edit/84117 Del: integrated -- https://master.php.net/note/delete/84117/integrated Del: useless -- https://master.php.net/note/delete/84117/useless Del: bad code -- https://master.php.net/note/delete/84117/bad+code Del: spam -- https://master.php.net/note/delete/84117/spam Del: non-english -- https://master.php.net/note/delete/84117/non-english Del: in docs -- https://master.php.net/note/delete/84117/in+docs Del: other reasons-- https://master.php.net/note/delete/84117 Reject -- https://master.php.net/note/reject/84117 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140900) next »