Explain how this custom function works PHP

后端 未结 2 736
长情又很酷
长情又很酷 2021-01-18 04:45

Here this function in PHP that allows to merge any N amount of different length arrays in a fashion that output array will be in next order: Array1[0],Array2[0],..,Arr

2条回答
  •  离开以前
    2021-01-18 05:12

    Inside array_zip_merge, the for statement always takes the first values of each array and add them to output variable respectively.

    Because array_shift removes the element it returns, on every loop the first elements are different. When it gets empty because of it, the loop has nothing to do and breaks.

    If you still dont understand, ask the specific part of the code you have trouble with please.

提交回复
热议问题