I have 2 kinds of ARRAYS
<?php
$array1 = array("Car", "House", "Money");
$array2 = array("John", "Peter", "Mary");
foreach ($array1 as $a1) {
for($i = 0; $i < count($array2); $i++) {
if ($a1 === end($array1 )) {
echo $array2[$i].' has '.$a1.'.<br>';
}
else {
echo $array2[$i].' has '.$a1.',<br>';
}
}
}
?>
But the output is like this
John has Car,
Peter has Car,
Mary has Car,
John has House,
Peter has House,
Mary has House,
John has Money.
Peter has Money.
Mary has Money.
What I want is like this
John has Car,
Peter has House,
Mary has Money.
is there any other way?
except for calling the specific value of an array like this
$array1[0]."has ".$array2[0].",<br>"
$array1[1]." has ".$array2[1].",<br>"
$array1[2]." has ".$array2[2].".<br>"
if I need to use "break;" where should I put it?
TIA