3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'list/jhon/july-8-2023/', 'list/jhon-july-8-2023/', 'list/jhon/july-8-2023', 'list/jhon-july-8-2023', 'list/8-2023-jhon-july/', 'list/8-2023-jhon-july-some-thing-more-than-desired/', ]; $patterns = [ 'simple' => '^list/(\w+)-(.*)/$', 'explicit' => '^list/([a-z]+)-([a-z]+-\d{1,2}-\d{4})/?$', 'optional' => '^list/(\w+)[\-/](\w+-\d{1,2}-\d{4})/?$' ]; foreach($patterns as $type => $p) { echo $type . ' pattern ' . $p . PHP_EOL; foreach($urls as $url) { preg_match("#$p#", $url, $matches); if ($matches) { echo $url . ': ' . var_export($matches, true) . PHP_EOL; } } echo PHP_EOL . PHP_EOL; }
Output for git.master_jit, git.master, rfc.property-hooks
simple pattern ^list/(\w+)-(.*)/$ list/jhon-july-8-2023/: array ( 0 => 'list/jhon-july-8-2023/', 1 => 'jhon', 2 => 'july-8-2023', ) list/8-2023-jhon-july/: array ( 0 => 'list/8-2023-jhon-july/', 1 => '8', 2 => '2023-jhon-july', ) list/8-2023-jhon-july-some-thing-more-than-desired/: array ( 0 => 'list/8-2023-jhon-july-some-thing-more-than-desired/', 1 => '8', 2 => '2023-jhon-july-some-thing-more-than-desired', ) explicit pattern ^list/([a-z]+)-([a-z]+-\d{1,2}-\d{4})/?$ list/jhon-july-8-2023/: array ( 0 => 'list/jhon-july-8-2023/', 1 => 'jhon', 2 => 'july-8-2023', ) list/jhon-july-8-2023: array ( 0 => 'list/jhon-july-8-2023', 1 => 'jhon', 2 => 'july-8-2023', ) optional pattern ^list/(\w+)[\-/](\w+-\d{1,2}-\d{4})/?$ list/jhon/july-8-2023/: array ( 0 => 'list/jhon/july-8-2023/', 1 => 'jhon', 2 => 'july-8-2023', ) list/jhon-july-8-2023/: array ( 0 => 'list/jhon-july-8-2023/', 1 => 'jhon', 2 => 'july-8-2023', ) list/jhon/july-8-2023: array ( 0 => 'list/jhon/july-8-2023', 1 => 'jhon', 2 => 'july-8-2023', ) list/jhon-july-8-2023: array ( 0 => 'list/jhon-july-8-2023', 1 => 'jhon', 2 => 'july-8-2023', )

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:
105.09 ms | 409 KiB | 5 Q