Re: Converting Array

From: Date: Thu, 26 Jun 2003 07:24:05 +0000
Subject: Re: Converting Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-152927@lists.php.net to get a copy of this message
At 03:37 26.06.2003, John Wulff said: --------------------[snip]-------------------- >I've got an array in the following format: >Array ( [Jan-1999] => 36.04,140.35,319.53,324.07 [Feb-1999] => >1.78,71.78,320.58,141.97 ) > >I need it in the following format: >$example_data = array( > array("Feb-1999",1.78,71.78,320.58,141.97), > array("Jan-1999",36.04,140.35,319.53,324.07) >); --------------------[snip]-------------------- This should do: $array_output = array(); foreach ($array_input as $key => $data) { $atmp = explode(',',$data); array_unshift($atmp, $key); $array_output[] = $atmp; } May I ask why you're reformatting the array - maybe you could avoid this step? -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#152927) next »