3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function init(&$select, &$params){ $select = array('key'=>1, 'key2'=>'one', 'key3'=>3333.333); $params = array(); } //echo 'array_walk: '; init($select, $params); $start_time = microtime(TRUE); array_walk($select, function(&$val, $id) { $params[$id] = $val; $val = "{$id} = :{$id}"; }); $end_time = microtime(TRUE); $walk_time = $end_time - $start_time; //echo 'foreach: '; init($select, $params); $start_time = microtime(TRUE); foreach($select as $id => &$val){ $params[$id] = $val; $val = "{$id} = :{$id}"; }unset($val); $end_time = microtime(TRUE); $foreach_time = $end_time - $start_time; echo "<pre> ArrayWalk Time: ".sprintf('%.10F', $walk_time)." Foreach Time: ".sprintf('%.10F', $foreach_time)." array_walk > foreach: ".($walk_time > $foreach_time)." foreach > array_walk ".($foreach_time > $walk_time)."</pre>"; ?><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><?PHP highlight_file(__FILE__); ?></div><?PHP
Output for 5.4.0 - 5.5.3
Parse error: syntax error, unexpected end of file in /in/oL6SF on line 40
Process exited with code 255.
Output for 5.3.29
<pre> ArrayWalk Time: 0.0000078678 Foreach Time: 0.0000028610 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.28
<pre> ArrayWalk Time: 0.0000081062 Foreach Time: 0.0000028610 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.14, 5.3.27
<pre> ArrayWalk Time: 0.0000128746 Foreach Time: 0.0000038147 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.26
<pre> ArrayWalk Time: 0.0000109673 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.25
<pre> ArrayWalk Time: 0.0000069141 Foreach Time: 0.0000021458 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.24
<pre> ArrayWalk Time: 0.0000100136 Foreach Time: 0.0000038147 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.18, 5.3.23
<pre> ArrayWalk Time: 0.0000121593 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.22
<pre> ArrayWalk Time: 0.0000140667 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.16, 5.3.21
<pre> ArrayWalk Time: 0.0000140667 Foreach Time: 0.0000050068 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.20
<pre> ArrayWalk Time: 0.0000109673 Foreach Time: 0.0000038147 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.19
<pre> ArrayWalk Time: 0.0000131130 Foreach Time: 0.0000038147 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.0, 5.3.11, 5.3.17
<pre> ArrayWalk Time: 0.0000119209 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.6, 5.3.15
<pre> ArrayWalk Time: 0.0000119209 Foreach Time: 0.0000050068 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.13
<pre> ArrayWalk Time: 0.0000109673 Foreach Time: 0.0000028610 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.4, 5.3.12
<pre> ArrayWalk Time: 0.0000090599 Foreach Time: 0.0000030994 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.10
<pre> ArrayWalk Time: 0.0000100136 Foreach Time: 0.0000028610 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.9
<pre> ArrayWalk Time: 0.0000112057 Foreach Time: 0.0000050068 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.8
<pre> ArrayWalk Time: 0.0000209808 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.7
<pre> ArrayWalk Time: 0.0000112057 Foreach Time: 0.0000030994 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.2, 5.3.5
<pre> ArrayWalk Time: 0.0000090599 Foreach Time: 0.0000028610 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.3
<pre> ArrayWalk Time: 0.0000100136 Foreach Time: 0.0000040531 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 5.3.1
<pre> ArrayWalk Time: 0.0000081062 Foreach Time: 0.0000030994 array_walk > foreach: 1 foreach > array_walk </pre><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><code><span style="color: #000000"> <span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'key'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key2'</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">'one'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'key3'</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3333.333</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />}<br /><br /><br /></span><span style="color: #FF8000">//echo&nbsp;'array_walk:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">array_walk</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;function(&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$id</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;});<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//echo&nbsp;'foreach:&nbsp;';<br /></span><span style="color: #0000BB">init</span><span style="color: #007700">(</span><span style="color: #0000BB">$select</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$start_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$select&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$id&nbsp;</span><span style="color: #007700">=&gt;&nbsp;&amp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$params</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">&nbsp;=&nbsp;:</span><span style="color: #007700">{</span><span style="color: #0000BB">$id</span><span style="color: #007700">}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}unset(</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$end_time&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">$start_time</span><span style="color: #007700">;<br /><br /><br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br /><br />ArrayWalk&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />&nbsp;&nbsp;Foreach&nbsp;Time:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">'%.10F'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br /><br />array_walk&nbsp;&gt;&nbsp;foreach:&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$walk_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$foreach_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />foreach&nbsp;&gt;&nbsp;array_walk&nbsp;"</span><span style="color: #007700">.(</span><span style="color: #0000BB">$foreach_time&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$walk_time</span><span style="color: #007700">).</span><span style="color: #DD0000">"&lt;/pre&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>&lt;div&nbsp;style="border:&nbsp;1px&nbsp;solid&nbsp;gray;&nbsp;width:&nbsp;640px;&nbsp;background-color:&nbsp;#F0F0F0"&gt;<br />Source&nbsp;Code&lt;br&gt;<span style="color: #0000BB">&lt;?PHP<br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>&lt;/div&gt;&lt;?PHP</span> </code></div><?PHP
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/oL6SF on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/oL6SF on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/oL6SF on line 11
Process exited with code 255.