note 50075 deleted from function.print-r by nlopess

From: Date: Thu, 14 Apr 2005 15:35:19 +0000
Subject: note 50075 deleted from function.print-r by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88012@lists.php.net to get a copy of this message
Note Submitter: Okkie ---- 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; }

« previous php.notes (#88012) next »