- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$items = array(
'<title>Something (TV 1999-2000)</title>'
,'<title>Something (1999-2000)</title>'
,'<title>Something (19999-2000)</title>'
,'<title>Something (99000)</title>'
,'<title>Something (2000)</title>'
);
$regex = "/<title>.*?\(.*?(\d{4}).*?\)<\/title>/is";
foreach($items AS $k => $str) {
preg_match($regex, $str, $matches[$k]);
}
print_r($matches);
?>