php - Retrieving data from multiple arrays using a while loop -
i'm looking way optimize following code using while loop.. i've got 4 arrays , pull 1st value each array in efficient way. original code works fine: $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]. " | " ; blow attempt optimize doesn't seems working: $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 < 5) { $result = "$arr".$x."