Log in

View Full Version : create a multidimensional array from a string?



james438
08-28-2007, 03:54 AM
$string="its all mr statum";
$array=explode(" ",$string);
$array1=$array[0];
$array1=explode("t",array1);
I'm trying to figure out a way to create a loop where you create a multidimensional array from a string, from the above nonsense code.

I need a hint :) I don't deal with multidimensional arrays much.

Twey
08-28-2007, 08:07 AM
$arr = array_map(create_function('$a', 'return explode(\'t\', $a);'), explode(' ', $string));

james438
08-28-2007, 05:10 PM
$string is the text data.
$arr is the multidimensional array I assume.
$a is?

Twey
08-28-2007, 05:16 PM
A parameter to the function I passed to array_map().

james438
08-29-2007, 02:30 AM
Thanks for that code, I have been having a lot of fun with it :)