note 98180 deleted from function.print by visualmind
| From: | visualmind@php.net | Date: | Mon, 31 May 2010 12:15:01 +0000 |
| Subject: | note 98180 deleted from function.print by visualmind | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169742@lists.php.net to get a copy of this message | ||
Note Submitter: yuwas at ht dot cx
----
For a recursive output of a multi-layer array, the following could be a solution:
<?php
function arr_render($arr){
if(is_array($arr)){
for($i =0, $result ='array('; $i < count($arr) -1; $i++){
$result .=arr_render($arr[$i]) .',';
};
$result .=arr_render($arr[$i]) .')';
return($result);
}else{
return((string) $arr);
};
};
$neighbourhood =array('Cheap Choice Center', array('Smith', 'Sally',
'sheep'), 'Packet Plus Postal Point', array(array('Mr. Mirst',
'Mrs. Mirst'),'Great Grocery'));
print(arr_render($neighbourhood));
?>
The result: array(Cheap Choice Center,array(Smith,Sally,sheep),Packet Plus Postal
Point,array(array(Mr. Mirst,Mrs. Mirst),Great Grocery))