note 73976 added to ref.array
| From: | info at joolee dot nl | Date: | Mon, 19 Mar 2007 12:49:56 +0000 |
| Subject: | note 73976 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124587@lists.php.net to get a copy of this message | ||
A slight modification in the arraytostring function, posted below. This function lists an array the
same way you would define it in PHP.
<?PHP
function arraytostring($array, $depth = 0)
{
if($depth > 0)
$tab = implode('', array_fill(0, $depth, "\t"));
$text.="array(\n";
$count=count($array);
foreach ($array as $key=>$value)
{
$x++;
if (is_array($value))
{
if(substr($text,-1,1)==')') $text .= ',';
$text.=$tab."\t".'"'.$key.'"'." =>
".arraytostring($value, $depth+1);
continue;
}
$text.=$tab."\t"."\"$key\" => \"$value\"";
if ($count!=$x) $text.=",\n";
}
$text.="\n".$tab.")\n";
if(substr($text, -4, 4)=='),),')$text.='))';
return $text;
}
?>
----
Server IP: 212.124.37.9
Probable Submitter: 194.45.157.197
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/73976
Del: integrated -- https://master.php.net/note/delete/73976/integrated
Del: useless -- https://master.php.net/note/delete/73976/useless
Del: bad code -- https://master.php.net/note/delete/73976/bad+code
Del: spam -- https://master.php.net/note/delete/73976/spam
Del: non-english -- https://master.php.net/note/delete/73976/non-english
Del: in docs -- https://master.php.net/note/delete/73976/in+docs
Del: other reasons-- https://master.php.net/note/delete/73976
Reject -- https://master.php.net/note/reject/73976
Search -- https://master.php.net/manage/user-notes.php