I need a little help with this.. i want to extract the playtime between span but i have a problem with title="PT because is changed on every span and i don't know how to replace that number to be able to extract all. This is the html code. Here is the code for extraction $playtime = explode("<span class=\"duration\" [B]title=\"PT"[/B], $track); $playtime = explode("</span>", $playtime[1]); $playtime = $playtime[0]; Code (markup): and this are the results I need to get rid of the 301"> parts.
$mystring='<span class="duration" title="PT301">3.01</span>'; $pos = strpos($mystring, ">"); $strright=substr ($mystring , $pos+1, strlen($mystring)-$pos-1); $result=str_replace("</span>","",$strright);
coladeu, Here is another option using preg_match_all (regular expressions): $string="<span class=\"duration\" title=\"PT301\">3.01</span> <span class=\"duration\" title=\"PT236\">2.36</span> <span class=\"duration\" title=\"PT433\">4.33</span>"; preg_match_all("|<span class=\"[^\"]*\" title=\"PT[^\"]*\">([^<]*)</span>|is",$string,$c); print_r($c);