I have two arrays like this:
$array_a = array('a','b','c','d');
$array_b = array('e','f','g','h');
Now I need to display my array values in this format:
a is e
b is f
c is g
d is h
How can do it?
I have two arrays like this:
$array_a = array('a','b','c','d');
$array_b = array('e','f','g','h');
Now I need to display my array values in this format:
a is e
b is f
c is g
d is h
How can do it?
This should work for you:
Just use array_map() to loop through both arrays:
array_map(function($v1, $v2){
echo $v1 . " is " . $v2 . "<br>";
}, $array_a, $array_b);
output:
a is e
b is f
c is g
d is h
Big advantage? Yes, It doesn't matter if one array is longer than the other one!