How to use a function to cross merge two arrays?

how do I use a function to cross merge two arrays?

Mar.04,2021

wrote a method that I don't know if it is what the landlord wants, as follows:

function jiaochaArray($arr1, $arr2)
{
    $arr1 = array_values($arr1);
    $arr2 = array_values($arr2);
    $count = max(count($arr1), count($arr2));
    $arr = array();
    for ($i = 0; $i < $count; $iPP) {
        if ($i < count($arr1)) $arr[] = $arr1[$i];
        if ($i < count($arr2)) $arr[] = $arr2[$i];
    }
    return $arr;
}

function mergeArr(arr1, arr2) {
  let arr = arr1.slice(0)
  arr2.forEach((item, index) => {
    arr.splice(2 * (index + 1) - 1, 0, item)
  })
  return arr
}

array_intersect ()

If the

system is ready-made, don't write it yourself

Menu