Jump to content

[SOLVED] Remove style tags


The Little Guy

Recommended Posts

I use this function to grab things inside of markers

you can use preg_replace on it

its the concept I suppose of what you're asking, play around with it, also your problem might be stripping line breaks before you parse through any source code, <span> is different from <span>\n

 

function get_insideMarkers($left, $right, $raw) {
$leftMarker = preg_quote($left, '/');
$rightMarker = preg_quote($right, '/');
$findBulk = preg_match_all('/'.$leftMarker.'(.*?)'.$rightMarker.'/', $raw, $array);
$resultArray = $array[1];
return $resultArray;
}

function stripnl($text) {
$text = str_replace("\r\n", "", $text);
$text = str_replace("\r", "", $text);
$text = str_replace("\n", "", $text);
return trim($text);
}

$raw = stripnl(file_get_contents('url'));
$array = get_insideMarkers('<span>', '</span>', $raw);
print_r($array); //returns all span tags

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.