creating of multi dimensional arrays with unknown depth

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

I got a string which include information for categories that I need to build, the string is built like this:
$string	= "val1~~val2~~val3~~val4~~val5"

Now, I want to create from this string a multi dimensional array and not one dimension array as explode('~~', $string) will give me.

The desired result from this string is:

$array['val1']	= 'whatever';
$array['val1']['val2']	= 'whatever';
$array['val1']['val2']['val3']	= 'whatever';
$array['val1']['val2']['val3']['val4']	= 'whatever';
$array['val1']['val2']['val3']['val4']['val'5]	= 'whatever';

My problem is that the number of the dimensions is really unknown and can be changed from 1 to 20 as far as I know.

Is there a way to create such a dynamic depth in an automatic way and not by using lots of if's?

Thanks in advance,
Ben-Nes Yonatan
Canaan Surfing Ltd.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux