3v4l.org

run code in 300+ PHP versions simultaneously
<?php $groupmap = ['one' => '/', 'two' => '/about', 'three' => '/about/class/(?<id>[^/]+)/fox', 'five' => '/about/class/(?<id>[^/]+)/(?<type>[^/]+)/fox/(?<boat>[^/]+)']; $regex = '~^(?:(?<one>/)|(?<two>/about)|(?<three>/about/class/(?<idthree>[^/]+)/fox)|(?<four>/about/class/(?<idfour>[^/]+)/(?<typefour>[^/]+)/fox)|(?<five>/about/class/(?<idfive>[^/]+)/(?<typefive>[^/]+)/fox/(?<boatfive>[^/]+)))$~x'; if (preg_match($regex, '/about/class/test1/test2/fox/someboat', $m)) { foreach ($groupmap as $name => $pattern ) { if (isset($m[$name]) && !empty($m[$name])) { echo "Group '" . $name . "' matched: " . $pattern . "\n"; echo "ID: " . (!empty($m["id".$name]) ? $m["id".$name] : "None") . "\n"; echo "TYPE: " . (!empty($m["type".$name]) ? $m["type".$name] : "None") . "\n"; echo "BOAT: " . (!empty($m["boat".$name]) ? $m["boat".$name] : "None"); } } }
Output for git.master, git.master_jit, rfc.property-hooks
Group 'five' matched: /about/class/(?<id>[^/]+)/(?<type>[^/]+)/fox/(?<boat>[^/]+) ID: test1 TYPE: test2 BOAT: someboat

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