This first block of code works as expected. It's a foreach
to print values from an $fnames
key-value array.
foreach($fnames as $fname){
echo $fname;
}
The $fnames
array has an $lnames
array that correspond to it, and I'd like to print the lname with the fname at the same time, something like this: but it doesn't compile
foreach($fnames as $fname && $lnames as $lname){
echo $fname . " " . $lname;
}
I also tried this, but that too doesn't compile.
foreach($fnames,$lnames as $fname,$lname){
echo $fname . " " . $lname;
}
The only thing that compiled was this, but it didn't give correct results.
foreach($fnames as $fname){
foreach($lnames as $lnames){
echo $fname . " " . $lname;
}
}
How do I get this sort of pairing between the 2 arrays at the same index?