Creating multidimensional array
| From: | Yonatan Ben-Nes | Date: | Thu, 21 Dec 2006 12:54:30 +0000 |
| Subject: | Creating multidimensional array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246118@lists.php.net to get a copy of this message | ||
Hi all,
I got a problem with creating a multidimensional array which it's size is
unknown.
I already made it work like this (example):
<?php
$array = array('six','five','four','three','two','one');
for ($i = count($array)-1; $i >= 0; $i--) {
$array_keys_string_representation .= '["'.$array[$i].'"]';
}
eval('$new_array'.$array_keys_string_representation.'["node_title"] =
"string value";');
?>
The problem is that I don't like using eval() cause it's slow &
insecure.....
I want to do something like this (doesn't work):
<?php
$array = array('six','five','four','three','two','one');
for ($i = count($array)-1; $i >= 0; $i--) {
$array_keys_string_representation .= '["'.$array[$i].'"]';
}
$new_array.$array_keys_string_representation.'["node_title"] = "string
value";
?>
Anyone got any idea how can I build such an array without eval()?
Thanks a lot in advance,
Ben-Nes Yonatan