note 46438 deleted from ref.array by aidan
| From: | aidan@php.net | Date: | Sun, 09 Oct 2005 09:14:44 +0000 |
| Subject: | note 46438 deleted from ref.array by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96736@lists.php.net to get a copy of this message | ||
Note Submitter: hadi_rastgou at yahoo dot com
----
A recursive function for TRNSFORMING nested arrays to a STRING:
#This recursive function transforms array indexs
#and their vlaues to a string
function array_to_str($array){
$str_of_array_keys_n_vals = "";
foreach($array as $key=>$val){
if(is_array($val)){
$str_of_array_keys_n_vals .= "[$key = {". array_to_str($val)."}] , ";
}
else{
$str_of_array_keys_n_vals .= "[$key=$val] , ";
}
}
return substr($str_of_array_keys_n_vals, 0, strlen($str_of_array_keys_n_vals)-3);
}
Array (
[ou] => My Test
[description] => ee
[objectclass] => Array (
[0] => top
[1] => organizationalunit
)
)
Will be
[ou=My Test] , [description=ee] , [objectclass = {[0=top] , [1=organizationalunit]}]