You are here: creating of multi dimensional arrays with unknown depth « PHP « IT news, forums, messages
creating of multi dimensional arrays with unknown depth

Posted by Ben-Nes Yonatan on 07/11/05 20:56

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация