[Solved] How to interleavedly duplicate an array in php?

Looks like a reasonably simple reduction (using array_reduce()) $x = array_reduce($x, function($arr, $val) { array_push($arr, $val, $val); return $arr; }, []); Demo ~ https://3v4l.org/eNH8a Just realised that “reduction” sounds a bit funny since we’re making the array bigger. Think of it more as a transformation. See https://en.wikipedia.org/wiki/Reduce_(parallel_pattern) 2 solved How to interleavedly duplicate an array … Read more