Get array with results of object method on each item in an array of objects in PHP
<p>I have an array of objects and I want to convert it to an array of the result of a method of each of them.  I can do this just fine, but I'm wondering if there is a cleaner / better approach to it maybe?  For example, pretend this is what I'm working with and how I'm doing it now:</p>

<pre><code>$objects = array();

$objects[] = new Dog();
$objects[] = new Dog();
$objects[] = new Dog();

$data = array();
foreach ($objects as $obj) {
  $data[] = $obj-&gt;myMethod();
}
</code></pre>

<p>Obviously this isn't super important, but it'd be nice to know about better ways to produce <code>$data</code> from <code>$objects</code> in the future.  Any ideas?  I was thinking there was some function for this, like <code>array_map()</code> or something but I'm not finding it.</p>
