PHP array union (linear product) -


Is there a way to get a union of two or more arrays?

Example:

$ array1 = [x1, x2, x3]; $ Array2 = [y1, y2, y3]; // and the result will be $ array2 = [x1 y1, x1 y2, x1 y3, x2 y1, x2 y2, .....];

This should work for you:

  & Lt ;; Php $ array1 = array ("x1", "x2", "x3" $ array2 = array ("y1", "y2", "y3"); $ array3 = array (); // and result will be $ $ 3 = [X1 y1, x1 y2, x1 y3, x2 y1, x2 y2, ...] for ($ count = 0; $ count & lt; count ($ array1); $ count ++) {$ CountArrayTwo = 0 ; $ CountArrayTwo & lt; Count ($ array2); $ countArrayTwo ++) $ array3 [] = $ array1 [$ count]. "$. $ Array2 [$ countArrayTwo];} print_r ($ array3) ;; & gt;  

Comments