note 80774 added to function.print-r

From: Date: Thu, 31 Jan 2008 12:52:55 +0000
Subject: note 80774 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-135646@lists.php.net to get a copy of this message
A simple function that will output an array more easily to read than print_r(); <?php function echo_array($array,$return_me=false){ if(is_array($array) == false){ $return = "The provided variable is not an array."; }else{ foreach($array as $name=>$value){ if(is_array($value)){ $return .= ""; $return .= "['<b>$name</b>'] {<div style='margin-left:10px;'>\n"; $return .= echo_array($value,true); $return .= "</div>}"; $return .= "\n\n"; }else{ if(is_string($value)){ $value = "\"$value\""; } $return .= "['<b>$name</b>'] = $value\n\n"; } } } if($return_me == true){ return $return; }else{ echo "<pre>".$return."</pre>"; } } ?> ---- Server IP: 213.249.64.162 Probable Submitter: 212.127.142.140 ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit -- https://master.php.net/note/edit/80774 Del: integrated -- https://master.php.net/note/delete/80774/integrated Del: useless -- https://master.php.net/note/delete/80774/useless Del: bad code -- https://master.php.net/note/delete/80774/bad+code Del: spam -- https://master.php.net/note/delete/80774/spam Del: non-english -- https://master.php.net/note/delete/80774/non-english Del: in docs -- https://master.php.net/note/delete/80774/in+docs Del: other reasons-- https://master.php.net/note/delete/80774 Reject -- https://master.php.net/note/reject/80774 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135646) next »