Re: multi-dimensional arrays

From: Date: Mon, 13 Apr 2009 19:08:56 +0000
Subject: Re: multi-dimensional arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-291442@lists.php.net to get a copy of this message
I think the best way would be: $arrays = explode(PHP_EOL, $field); foreach ($arrays as &$array) { $array = explode(" ", $array); } Not tested, but should work. "Andres Gonzalez" <andres@packetstorm.com> escreveu na mensagem news:49E38A9E.3090600@packetstorm.com... > 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 > > >

« previous php.general (#291442) next »