title: Is this a fair method of algorithm comparison?
body: <p>I wanted to convert an array to lowercase and was wondering the most efficient method.  I came up with two options, one using array_walk and one using foreach and wanted to compare them.  Is this the best way to compare the two?  Is there an even more efficient method that I have overlooked?</p>
  
  <pre><code>&lt;?
  $a = array_fill(0, 200000, genRandomString());
  $b = array_fill(0, 200000, genRandomString());
  $t = microtime(true);
  array_walk($a, create_function('&amp;$a', '$a = strtolower($a);'));
  echo "array_walk: ".(microtime(true) - $t);
  echo "&lt;br /&gt;";
  $t = microtime(true);
  foreach($b as &amp;$source) { $source = strtolower($source); }
  echo "foreach: ".(microtime(true) - $t);
  
  
  function genRandomString($length = 10) {
      $characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
      $string = '';    
  
      for ($p = 0; $p &lt; $length; $p++) {
          $string .= $characters[mt_rand(0, strlen($characters)-1)];
      }
  
      return $string;
  }
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>array_walk: 0.52975487709045
  foreach: 0.29656505584717
  </code></pre>