- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$string = 'application/vnd.github.full+json';
function match($string) {
$pattern = '#(?P<maintype>[a-z].*)/(?P<fullsubtype>(?P<subtype>[a-z0-9.-]*)([+](?P<submediatype>[a-z]*))?)#i';
preg_match($pattern, $string, $matches);
return $matches;
}
var_dump(match('application/vnd.github.full+json'));
var_dump(match('text/html'));