Re: array conversion
| From: | Richard Quadling | Date: | Fri, 19 Feb 2010 16:56:56 +0000 |
| Subject: | Re: array conversion | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302209@lists.php.net to get a copy of this message | ||
On 19 February 2010 15:52, tedd <tedd.sperling@gmail.com> wrote:
> At 10:48 AM +0000 2/19/10, Richard Quadling wrote:
>>
>> On 19 February 2010 07:26, Adam Richardson <simpleshot@gmail.com> wrote:
>> Or,
>
> Code fight!!!
>
> http://www.webbytedd.com/ccc/array/
>
> After reviewing the entries, mine does not provide any significant
> difference. I did it as a mental exercise after looking at several built-in
> array functions (array_flip(), array_combine(), etc. ) that I thought might
> solve the problem, but didn't.
>
> tedd
> --
> -------
> http://sperling.com
> http://ancientstones.com
> http://earthstones.com
>
Just wanting to join in.
<?php
$array = array
(
'key1',
'value1',
'key2',
'value2',
);
$result = array();
while(!is_null($result[array_shift($array)] = array_shift($array)));
array_pop($result);
print_r($result);
?>
outputs ...
Array
(
[key1] => value1
[key2] => value2
)
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling