Is there a native PHP function to zip merge two arrays?
Look at the following example:
$a = array(\"a\",\"b\",\"c\");
$b = array(\"d\",\"e\",\"f\");
There is no PHP native function for this purpose. However according to the comment of @Mark Baker there is a short possibility to implement this:
$a = array("a","b","c");
$b = array("d","e","f");
$c = array("g","h","i");
function array_zip(...$arrays) {
return array_merge(...array_map(null, ...$arrays));
}
var_dump(array_zip($a,$b,$c));