Here's a function I wrote a while ago. It might do the job for you:
function get_enclosed_text($str, $open, $close)
{
$str = str_replace(array(strtoupper($open), strtoupper($close)),
array(strtolower($open), strtolower($close)), $str);
$arr = explode(strtolower($open), $str);
$text = array();
foreach ($arr as $substr) {
if (($pos = strpos($substr, strtolower($close))) !== false) {
$text[] = substr($substr, 0, $pos);
}
}
return $text;
}
Usage:
$input = 'this is some text with <small>tags</small> <small>in it</small>.';
$text_arr = get_enclosed_text($input, '<small>', '</small>');
if (!empty($text_arr)) {
foreach ($text_arr as $key => $value) {
echo $key . ' => ' . $value . '<br />';
}
}