Performance question about create_function
| From: | Mathieu Suen | Date: | Mon, 19 Oct 2009 12:13:39 +0000 |
| Subject: | Performance question about create_function | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-45843@lists.php.net to get a copy of this message | ||
Hi,
Looking at the way array_map is working, it could worth to use create_function for object.
For example if I got a list of object:
$callback = create_function($element, 'return $selement->getId();');
$ids = array_map($callback, $someInstances);
But I don't know if it's cost a lot in performance instead of the ugly verbose way:
$ids = array();
foreach($someInstances)
{
$ids[] = $someInstances->getId();
}
Of course I don't expect it to be faster but I hope that could worth the cost.
Thanks
--
-- Mathieu Suen
--