php - Loop through two arrays and display one data of each -


i want create string composed 2 data 2 different arrays. loop through both arrays 2 foreach data. problem want loop @ same time both of foreach.

so example (just example, these arrays aren't real), have first array :

array1 =('apple','orange','banana','lemon');

and second array :

array2 =('juice','fruit','split','tree');

and want loop through these arrays , create string :

"apple juice", "orange fruit", "banana split", "lemon tree"

with function, :

"apple juice", "orange juice", "banana juice", "lemon juice"

i heard recursive function don't know how or if it's best way.

so code :

foreach ($xml $table)                   {                     foreach ($table $champs)  /                     {                         foreach($array $ligne)                         {                             foreach($ligne $elt)                             {                                 if ($table['nom']=='traitement')                                  {                                     $stringupdate .= '\''.$champs->nom.'=\''.$elt.'\',';                                      break 2;                                 }                             }                         }update_traitement($stringupdate);                         $stringupdate='';                     }                 } 

can me please ? don't know how it.

edit :

concretly, have 1 array data xml file , other array handsontable. second array two-dimensional, that's why need use 4 foreach.

i need loop through rows , through columns of second array, , think simple foreach not match.

you need 1 foreach

$array1 =('apple','orange','banana','lemon'); $array2 =('juice','fruit','split','tree'); foreach($array1 $i=>$value){  echo $value." ".$array2[$i]; } 

Comments