note 86657 added to function.print-r

From: Date: Tue, 28 Oct 2008 18:53:19 +0000
Subject: note 86657 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-145896@lists.php.net to get a copy of this message
This is an alternative for printing arrays. It bolds array values. function print_array(&$a, $str = "") { if ($str[0]) { echo "$str ="; } echo ' array( '; foreach ($a as $k => $v) { echo "[$k]".' => '; if (is_array($v)) { print_array($v); } else { echo "<strong>$a[$k]</strong> "; } } echo ') '; } $a1 = array ("apples", "oranges", "pears"); $a2 = array ("potatos", "green beans", "squash"); $a3 = array ("euros", "dollars", "pesos", "dinars"); $test = range(1, 9); array_push($test, array ("fruit" => $a1, "vegies" => $a2, "money" => $a3)); print_array($test, "test"); ---- Server IP: 64.71.164.2 Probable Submitter: 71.170.222.197 ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit -- https://master.php.net/note/edit/86657 Del: integrated -- https://master.php.net/note/delete/86657/integrated Del: useless -- https://master.php.net/note/delete/86657/useless Del: bad code -- https://master.php.net/note/delete/86657/bad+code Del: spam -- https://master.php.net/note/delete/86657/spam Del: non-english -- https://master.php.net/note/delete/86657/non-english Del: in docs -- https://master.php.net/note/delete/86657/in+docs Del: other reasons-- https://master.php.net/note/delete/86657 Reject -- https://master.php.net/note/reject/86657 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145896) next »