3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = [['A','B','C'],[1,2,3],[4,5,6],[7,8,9]]; $headers = array_shift($x); array_walk( $x, function(&$row) use ($headers) { $row = array_combine($headers, $row); } ); $y = json_export($x,true); echo $y;

preferences:
46.21 ms | 402 KiB | 5 Q