3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['Categoria' => 'example', 'Servico' => 'name1'], ['Categoria' => 'example', 'Servico' => 'name2'], ['Categoria' => 'example', 'Servico' => 'name3'], ['Categoria' => 'example2', 'Servico' => 'name4'], ['Categoria' => 'example2', 'Servico' => 'name5'], ['Categoria' => 'example2', 'Servico' => 'name6'], ['Categoria' => 'example3', 'Servico' => 'name7'], ['Categoria' => 'example3', 'Servico' => 'name8'], ['Categoria' => 'example3', 'Servico' => 'name9'] ]; var_export( array_values( array_reduce( $array, function ($carry, $row) { $carry[$row['Categoria']]['Servico'] = $row['Categoria']; $carry[$row['Categoria']]['children'][] = $row['Servico']; return $carry; } ) ) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'Servico' => 'example', 'children' => array ( 0 => 'name1', 1 => 'name2', 2 => 'name3', ), ), 1 => array ( 'Servico' => 'example2', 'children' => array ( 0 => 'name4', 1 => 'name5', 2 => 'name6', ), ), 2 => array ( 'Servico' => 'example3', 'children' => array ( 0 => 'name7', 1 => 'name8', 2 => 'name9', ), ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
63.71 ms | 406 KiB | 5 Q