Re: Converting Array
| From: | David Otton | Date: | Thu, 26 Jun 2003 02:09:21 +0000 |
| Subject: | Re: Converting Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152901@lists.php.net to get a copy of this message | ||
On Wed, 25 Jun 2003 18:37:02 -0700, you wrote:
>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 )
Assuming that I've interpreted your array structure correctly,
$a = array ("Jan-1999" => array (36.04,140.35,319.53,324.07),
"Feb-1999" => array (1.78,71.78,320.58,141.97)
);
There are plenty of possible solutions. Here's a slightly perverse one:
$f = create_function ('$x, $y', 'return (array_merge(array($x), $y));');
$a = array_map($f, array_keys ($a), $a);
Otherwise... loop from 0 to sizeof ($array), replacing each element of the
array with
array($key) + $value