note 46438 added to ref.array
| From: | hadi_rastgou at yahoo dot com | Date: | Mon, 11 Oct 2004 16:57:04 +0000 |
| Subject: | note 46438 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78359@lists.php.net to get a copy of this message | ||
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]}]
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46438
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46438&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46438&report=yes
Search -- http://master.php.net/manage/user-notes.php