Matrix transposition: Difference between revisions

Content deleted Content added
Line 2,404: Line 2,404:
====Starting with PHP 5.6====
====Starting with PHP 5.6====
<lang php>
<lang php>
// code by Let's say Pie
function transpose($m) {
function transpose($m) {
return count($m) == 0 ? $m : (count($m) == 1 ? array_chunk($m[0], 1) : array_map(null, ...$m));
return count($m) == 0 ? $m : (count($m) == 1 ? array_chunk($m[0], 1) : array_map(null, ...$m));