Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize | SQLize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $collection = collect([ ['a' => 1, 'b' => 'x', 'c' => true], ['b' => 'y', 'a' => '2', 'c' => false], ['c' => null, 'b' => 'z', 'a' => 3] ]); var_export( $collection->reduce( function($result, $row, $i) { collect($row)->each(function($v, $k) use (&$result, $i) { $result[$k][$i] = $v; }); return $result; }, [] ) );
Copy Clear