[pmwiki-devel] php multi-dimensional array construction problem

Hans design5 at softflow.co.uk
Thu Feb 5 08:48:55 CST 2009


Thursday, February 5, 2009, 2:28:34 PM, Daniel wrote:

> $string = "k1:k2:k3:...:kn";
> $array = explode(":", $string);

> //Contents of $array is now:
> // Array
> // {
//    [0] =>> k1
//    [1] =>> k2
//    [2] =>> k3
> //    ...
//    [n-1] =>> kn
> // }

> Avast!

I got so far, but the "avast!" defeats me. Perhaps I am thick ;-)

How do I construct out of that nice flat array this array-element:

n deep array $arr
element needed
   $val = arr[$k[0]][$k[1]][$k[2]]....[$k[$n]];
or element set
   $arr[$k[0]][$k[1]][$k[2]]....[$k[n]] = $val;

How can the ... be constructed, with n being a variable integer?

Thanks,
Hans




More information about the pmwiki-devel mailing list