NYCPHP Meetup

NYPHP.org

[nycphp-talk] efficient array manipulation

Dan Cech dcech at phpwerx.net
Thu Apr 28 18:57:50 EDT 2005


Joel De Gan wrote:
> See: 
> http://us2.php.net/manual/en/function.array-map.php

Good point,

I tested this:

function callback2($v)
{
   return array(
     'element1' => $v,
     'element2' => 'myval'
   );
}

$myarr = array_map(create_function('$v','return 
array_map(\'callback2\',$v);'),$myarr);

And it seems to be consistently faster than the other three methods in 
my previous email (possibly because it doesn't have to throw a bunch of 
references around).

Dan




More information about the talk mailing list