3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = "Faktura č.: XYZ za období 01/2017"; preg_match("~^\\s*Faktura\\s+č.:\\s*(?P<invoice>\S+)(?:\\s+za\\s+období\\s+0?(?P<month>\\d{1,2})\\s*/\\s*(?P<year>\\d{4}))?\\s*$~iu", $str, $matches); var_dump($matches);
based on jgvc6
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6
array(7) { [0]=> string(35) "Faktura č.: XYZ za období 01/2017" ["invoice"]=> string(3) "XYZ" [1]=> string(3) "XYZ" ["month"]=> string(1) "1" [2]=> string(1) "1" ["year"]=> string(4) "2017" [3]=> string(4) "2017" }