|  | Posted by Jerry Stuckle on 02/07/07 18:11 
Generale Cluster wrote:> 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.
 > Is it possible? How to do this?
 >
 > I tried with:
 >
 > array_walk($list,create_function('$a,$b,$result','$result[] =
 > $a->member2;'), &$result);
 >
 > but I get the following error:
 >
 > Warning: Call-time pass-by-reference has been deprecated - argument
 > passed by value; If you would like to pass it by reference, modify the
 > declaration of array_walk(). If you would like to enable call-time
 > pass-by-reference, you can set allow_call_time_pass_reference to true in
 > your INI file. However, future versions may not support this any longer.
 >
 > Thank you
 > Regards
 
 
 Try:
 
 array_walk($list,create_function('$a,$b,&$result','$result[] =
 $a->member2;'), $result);
 
 Specify the reference in the parameter list, not when passing the value.
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |