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
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.