Re: array conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 February 2010 15:52, tedd <tedd.sperling@xxxxxxxxx> wrote:
> At 10:48 AM +0000 2/19/10, Richard Quadling wrote:
>>
>> On 19 February 2010 07:26, Adam Richardson <simpleshot@xxxxxxxxx> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux