This first block of code works as expected. This is a foreach for printing values from an array of $fnames values.
foreach($fnames as $fname){ echo $fname; }
The $fnames array has an $lnames array that matches it, and I would like to print lname with the name fname at the same time, something like this: but it does not compile
foreach($fnames as $fname && $lnames as $lname){ echo $fname . " " . $lname; }
I tried this too, but this does not compile either.
foreach($fnames,$lnames as $fname,$lname){ echo $fname . " " . $lname; }
The only thing that was compiled, but it did not give the correct results.
foreach($fnames as $fname){ foreach($lnames as $lnames){ echo $fname . " " . $lname; } }
How do I get this kind of pairing between two arrays at the same index?
source share