3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $subject = "1st from last"; preg_match('~(?P<index>[0-9]+)(?:st|nd|rd|th)* from (?P<position>last|end|start|beginning)+~', $subject, $matches); var_dump($matches);
Output for 4.3.3 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(5) { [0]=> string(13) "1st from last" ["index"]=> string(1) "1" [1]=> string(1) "1" ["position"]=> string(4) "last" [2]=> string(4) "last" }
Output for 4.3.0 - 4.3.2
array(3) { [0]=> string(13) "1st from last" [1]=> string(1) "1" [2]=> string(4) "last" }