3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a1 = [ 'from' => 'Paris', 'to' => 'Marseille', ]; $a2 = [ 'from' => 'Marseille', 'to' => 'Valencia', ]; $a3 = [ 'from' => 'Valencia', 'to' => 'Algiers', ]; $a4 = [ 'from' => 'Algiers', 'to' => 'Abu Dhabi', ]; $route = array($a4, $a3, $a1, $a2); $from = array_column($route, 'from'); $to = array_column($route, 'to'); $start = array_diff($from, $to); $sortedRoute = [$route[key($start)]]; $start = $route[key($start)]['to']; while (true) { $key = array_search($start, $from); if ($key === false) break; $sortedRoute[] = $route[$key]; $start = $route[$key]['to']; } var_dump($sortedRoute);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(2) { ["from"]=> string(5) "Paris" ["to"]=> string(9) "Marseille" } [1]=> array(2) { ["from"]=> string(9) "Marseille" ["to"]=> string(8) "Valencia" } [2]=> array(2) { ["from"]=> string(8) "Valencia" ["to"]=> string(7) "Algiers" } [3]=> array(2) { ["from"]=> string(7) "Algiers" ["to"]=> string(9) "Abu Dhabi" } }

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:
30.59 ms | 406 KiB | 5 Q