title: Retrieving data from multiple arrays using a while loop
body: <p>I'm looking for a way to optimize the following code using while loop.. I've got 4 arrays and would like to pull the 1st value from each array in the most efficient way. This is the original code which works fine:</p>
  
  <pre><code>$arr1 = array ("55", "66", "77");
  $arr2 = array ("54", "64", "771");
  $arr3 = array ("53", "62", "772");
  $arr4 = array ("52", "60", "773");
  $x = 1;
  $result = "null";
  
  echo $arr1[0] . " | " ; 
  echo $arr2[0]. " | " ; 
  echo $arr3[0]. " | " ; 
  echo $arr4[0]. " | " ; 
  </code></pre>
  
  <p>Blow is my attempt to optimize it but it doesn't seems to be working:</p>
  
  <pre><code>$arr1 = array ("55", "66", "77");
  $arr2 = array ("54", "64", "771");
  $arr3 = array ("53", "62", "772");
  $arr4 = array ("52", "60", "773");
  $x = 1;
  $result = "null";
  
  while($x &lt; 5) {
  $result = "$arr".$x."[0]";
  echo $result;
  echo " | ";
  $x = $x +1;
  }
  </code></pre>
  
  <p>The output I'm getting is
  1[1] | 2[1] | 3[1] | 4[1]<br>
  Instead of 
  55 | 54 | 53 | 52 |</p>
  
  <p>Thank you all!</p>