assuming both arrays have the same number of elements, this should work
foreach(array_combine($cars, $ages) as $car => $age){ echo $car.$age; }
if arrays are not guaranteed the same length, you can do something like this
$len = max(count($ages), count($cars)); for($i=0; $i<$len; $i++){ $car = isset($cars[$i]) ? $cars[$i] : ''; $age = isset($ages[$i]) ? $ages[$i] : ''; echo $car.$age; }
if you just want to join two arrays you can do it like this
foreach(array_merge($cars, $ages) as $key => $value){ echo $key . $value; }
source share