title: PHP - Is array_map faster than foreach?
body: <p>In terms of performance, which is the better option?</p>
  
  <p>While in object:</p>
  
  <p><strong>Case #1</strong></p>
  
  <pre><code>public function test( $array ) {
      return array_map( array( $this, 'do_something_to_element' ), $array );
  }
  </code></pre>
  
  <p><strong>Case #2</strong></p>
  
  <pre><code>public function test( $array ) {
      $return = array();
      foreach ( $array as $value ) {
          $return[] = do_something_to_element( $value );
      }
      return $return;
  }
  </code></pre>
  
  <p>There are other uses of course and many many examples can be populated. I've seen comments that while in an object, array_map is slower than foreach loops. </p>
  
  <p>In general is the array_map/array_walk functions faster to execute than the foreach loops in similar needs?</p>