|
Posted by Kimmo Laine on 02/08/07 12:02
"Generale Cluster" <alex@carrarosoftmasters.net> wrote in message
news:eqd099$uh6$1@newsreader.mailgate.org...
> Hello,
> I have the following situation:
>
> $list[] is an array of MyElement objects.
>
> MyElement has two members: MyElement->member1; MyElement->member2;
>
> What I want is to get the following:
>
> $newlist[] so that:
>
> $newlist[0]=$list[0]->member2;
> $newlist[1]=$list[1]->member2;
> $newlist[2]=$list[2]->member2;
> ...
>
> I need to do this using A SINGLE LINE OF CODE.
foreach($list as $foo) $newlist[] = $foo->member2;
> I tried with:
>
> array_walk($list,create_function('$a,$b,$result','$result[] =
> $a->member2;'), &$result);
"Gloves".
http://thedailywtf.com/Articles/The_Complicator's_Gloves.aspx
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|