3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cards = [ [ "from" => "Barcelona", "to" => "Gerona Airport", ], [ "from" => "Stockholm", "to" => "New York JFK", ], [ "from" => "Gerona Airport", "to" => "Stockholm", ], [ "from" => "New York JFK", "to" => "Amsterdam", ], [ "from" => "Amsterdam", "to" => "London", ], [ "from" => "Madrid", "to" => "Barcelona", ] ]; $result = []; function doSort($cards, &$result, $start = "Madrid") { foreach ($cards as $key => $card) { if ($card["from"] === $start) { $result[] = $card; doSort($cards, $result, $card["to"]); } } } doSort($cards, $result); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [from] => Madrid [to] => Barcelona ) [1] => Array ( [from] => Barcelona [to] => Gerona Airport ) [2] => Array ( [from] => Gerona Airport [to] => Stockholm ) [3] => Array ( [from] => Stockholm [to] => New York JFK ) [4] => Array ( [from] => New York JFK [to] => Amsterdam ) [5] => Array ( [from] => Amsterdam [to] => London ) )

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:
26.62 ms | 407 KiB | 5 Q