note 50751 deleted from function.print-r by nlopess
| From: | nlopess@php.net | Date: | Thu, 14 Apr 2005 15:35:14 +0000 |
| Subject: | note 50751 deleted from function.print-r by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-88011@lists.php.net to get a copy of this message | ||
Note Submitter: benles at bldigital dot com
----
string_r is missing variable declarations and should be called sprint_r anyway :)
function sprint_r($array, $idt=0)
{
$tabsize = " ";
$arg = func_get_args();
$indent = $idt;
if (func_num_args() == 1) $indent = $tabsize;
$contentString="";
foreach ($array as $name => $value)
{
if (is_array($value))
{
$contentString .= $indent.'['.$name.'] => Array' .
"\n".$indent.$tabsize."(\n";
$contentString .= sprint_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;
}