note 50075 added to function.print-r

From: Date: Thu, 17 Feb 2005 10:39:46 +0000
Subject: note 50075 added to function.print-r
Groups: php.notes 
Request: Send a blank email to php-notes+get-85154@lists.php.net to get a copy of this message
string_r does the same thing as print_r only it returns a string in stead of printing it. function string_r($array /*indent*/) { $tabsize = " "; $arg = func_get_args(); $indent = $arg[1]; if (func_num_args() == 1) $indent = $tabsize; foreach ($array as $name => $value) { if (is_array($value)) { $contentString .= $indent.'['.$name.'] => Array' . "\n".$indent.$tabsize."(\n"; $contentString .= string_r($value, $indent. $tabsize.$tabsize); $contentString .= $indent .$tabsize. ")\n\n"; } else { $contentString .= $indent . '['.$name.']' . ' => ' . $value . "\n"; } } if (func_num_args() == 1) { $contentString = "Array\n(\n" . $contentString . ")\n"; } return $contentString; } ---- Manual Page -- http://www.php.net/manual/en/function.print-r.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50075 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50075&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50075&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50075&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50075&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50075&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50075&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85154) next »