3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'type1' => array( 'id' => 'w12', 'name' => 'John Doe', 'email' => 'john@example.com', 'fname' => 'john', 'phone' => '111', 'age' => '22' ), 'type2' => array( 'id' => 'w13', 'name' => 'Jane Doe', 'email' => 'jane@example.com', 'age' => '22', 'phone' => '111', 'fname' => 'dsd' ), ); $order = [ 'id' => null, 'name' => null, 'fname' => null, 'phone' => null, 'age' => null, 'email' => null ]; $ordered = array_map(function($row) use ($order) { return array_merge($order, $row); }, $array); var_dump($ordered);
Output for git.master_jit, git.master, rfc.property-hooks
array(2) { ["type1"]=> array(6) { ["id"]=> string(3) "w12" ["name"]=> string(8) "John Doe" ["fname"]=> string(4) "john" ["phone"]=> string(3) "111" ["age"]=> string(2) "22" ["email"]=> string(16) "john@example.com" } ["type2"]=> array(6) { ["id"]=> string(3) "w13" ["name"]=> string(8) "Jane Doe" ["fname"]=> string(3) "dsd" ["phone"]=> string(3) "111" ["age"]=> string(2) "22" ["email"]=> string(16) "jane@example.com" } }

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:
36.56 ms | 402 KiB | 8 Q