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

Daniel Roesler diafygi at gmail.com
Thu Feb 5 08:28:34 CST 2009


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

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

Avast!
Daniel Roesler
diafygi at gmail.com

On Thu, Feb 5, 2009 at 4:40 AM, Hans <design5 at softflow.co.uk> wrote:
> Perhaps someone can help me out with this problem:
>
> I got a string k1:k2:k3:....:kn  and a value val
> made up of alpha-numeric word strings of any length
> k1 ..kn, seperated by :
> The number n of the k members can vary.
>
> I like to construct an array out of this like
> array[k1][k2][k3]....[kn] = val
> so each word string k will become a key of the array, in sequence of
> the original series, resulting in an array with n keys.
>
> Apologies for the shorthand leaving out $ and quotes for proper php.
>
>
> Thanks for any help!
>  Hans
>
>
> _______________________________________________
> pmwiki-devel mailing list
> pmwiki-devel at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-devel
>



More information about the pmwiki-devel mailing list