3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ "localhost/my_system/users", "localhost/my_system/users/add_user", "localhost/my_system/users/by_letter/groups", "localhost/my_system/users/add_group"]; $url = "localhost/my_system/users/by_letter/s"; function getClosestURL($url, $data){ $matches = []; $explodedURL = explode("/", $url); foreach ($data as $match) { $explodedMatch = explode("/", $match); $matches[] = array_intersect($explodedMatch, $explodedURL); } return count(max($matches)) > 0 ? implode("/", max($matches)) : false; } var_dump(getClosestURL($url, $data)); //returns localhost/my_system/users/by_letter var_dump(getClosestURL("local/no/match", $data)); //returns false
Output for git.master, git.master_jit, rfc.property-hooks
string(35) "localhost/my_system/users/by_letter" bool(false)

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:
131.92 ms | 405 KiB | 5 Q