Quick way:
Look at the index position tag1, then find the index position / tag 1. Then cut the line between the two indexes. Take a look at strpos and substr on php.net. Also, this may not work if your line is too long.
$pos1 = strpos($bigString, '<tag1>'); $pos2 = strpos($bigString, '</tag1>'); $resultingString = substr($bigString, -$pos1, $pos2);
You may need to add and / or subtract some units from $ pos1 and $ pos2 to get the correct value of $ resultString. (if you have no comments with tag1 inside them, sigh)
The right way:
Search for html parsers
source share