Transpose multidimensional array and join values with commas



PHP Snippet 1:

$i = 0;
while($new = array_column($array, $i)) {
    $result[] = implode(', ', $new);
    $i++;
}

PHP Snippet 2:

$array = array_map(function($v) { return array_values($v); }, $array);

PHP Snippet 3:

$arr = array_map(null, ...$arr);
$temp = array_map(function($item){
    return implode(", ", $item);
},$arr);

PHP Snippet 4:

Array
(
    [0] => 201767.11, 349399.51, 285169.05, 126858.21
    [1] => 514324.91, 647217.1, 522357.2, 185190.59
    [2] => 73205.74, 3500, 10, 0
)

PHP Snippet 5:

$temp = array_map(function ($item) {return implode(", ", $item); }, array_map(null, ...$arr)); 

PHP Snippet 6:

$array = [
    [201767.11, 514324.91, 73205.74],
    [349399.51, 647217.10, 3500.00],
    [285169.05, 522357.20, 10.00],
    [126858.21, 185190.59, 0],
];

var_export(array_map(fn() => implode(', ', func_get_args()), ...$array));

PHP Snippet 7:

var_export(array_map(fn(...$column) => implode(', ', $column), ...$array));

PHP Snippet 8:

array (
  0 => '201767.11, 349399.51, 285169.05, 126858.21',
  1 => '514324.91, 647217.1, 522357.2, 185190.59',
  2 => '73205.74, 3500, 10, 0',
)