Which of the two will be faster
<p>Which of the two will be faster and how can do such measurements</p>

<pre><code>foreach ($posts as $post)
{
 $totalikes = count($post["Like"]);
 $totacomments = count($post["Comment"]);
 $max = ($totalikes &lt; $totacomments )? $totacomments  : $totalikes;
 for($i=0;$i&lt;$max;$i++)
 {
  if(isset($post["Like"][$i]))
   $users[] = $post["Like"][$i]["user_id"];
  if(isset($post["Comment"][$i]))
   $users[] = $post["Comment"][$i]["user_id"];
 }
}
</code></pre>

<p>or</p>

<pre><code>foreach ($posts as $post)
{
 foreach ($post["Like"] as $like)
 {
  $users[] = $like["user_id"];
 }
 foreach ($post["Comment"] as $comment)
 {
  $users[] = $comment["user_id"];
 }
}
</code></pre>

<p>Which of the two is better</p>
