3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function parseHttpAcceptHeader($string) { $pattern = '#(?P<maintype>[a-z\*]*)/(?P<fullsubtype>(?P<subtype>[a-z0-9.\*-]*)([+](?P<submediatype>[a-z]*))?)(;q=(?P<quality>[0-9.]*))?#i'; preg_match($pattern, $string, $matches); return $matches; } $string = 'application/vnd.github.full+json;q=0.8'; var_dump(parseHttpAcceptHeader($string));
Output for 4.3.3 - 7.1.0
array(13) { [0]=> string(38) "application/vnd.github.full+json;q=0.8" ["maintype"]=> string(11) "application" [1]=> string(11) "application" ["fullsubtype"]=> string(20) "vnd.github.full+json" [2]=> string(20) "vnd.github.full+json" ["subtype"]=> string(15) "vnd.github.full" [3]=> string(15) "vnd.github.full" [4]=> string(5) "+json" ["submediatype"]=> string(4) "json" [5]=> string(4) "json" [6]=> string(6) ";q=0.8" ["quality"]=> string(3) "0.8" [7]=> string(3) "0.8" }
Output for 4.3.0 - 4.3.2
array(8) { [0]=> string(38) "application/vnd.github.full+json;q=0.8" [1]=> string(11) "application" [2]=> string(20) "vnd.github.full+json" [3]=> string(15) "vnd.github.full" [4]=> string(5) "+json" [5]=> string(4) "json" [6]=> string(6) ";q=0.8" [7]=> string(3) "0.8" }