Re: [PHP] array conversion

[email protected] (Richard Quadling)
Newsgroups php.general
Message-ID <[email protected]>
On 19 February 2010 15:52, tedd <[email protected]> wrote:
> At 10:48 AM +0000 2/19/10, Richard Quadling wrote:
>>
>> On 19 February 2010 07:26, Adam Richardson <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.