$string = "xxx xxxx xx xxxxx xx xxx xxx xxxx xx xxxxx xx xxx"; $t = explode("\n", $string); foreach ($t as $k => $v) $t[$k] = explode(" ", $v); var_dump($t); On Mon, Apr 13, 2009 at 8:55 PM, Andres Gonzalez <andres@xxxxxxxxxxxxxxx>wrote: > Hi, > > I am learning PHP and have a simple question. > I have a input string in this form: > > xxx xxxx xx xxxxx xx xxx > xx xxxxx x xxx xx xxxxxx > . > . > . > xx xxx xx xxxx xx xx > > each line has 6 words of various lengths, all separated by white space. > the input string can have any number of lines > > I want to put this into a multi-dimensional array, each line an array that > is an element of an outer array. > > I have tried various ways to do this--I have used explode() and > array_filter() and can get a single line parsed and into an array but I am > having problems getting a well formed 2 dim array. > > What is the easiest way to do this? With all of the PHP array functions, > there should be an very straight forward way to do this. > > Any help would be appreciated. > > -Andres > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >