Saturday, March 17, 2018

PHP parse HTML tags

Fast way:


Look for the index position of tag1 then look for the index position of /tag1. Then cut the string between those two indexes. Look up strpos and substr on php.net
Also this might not work if your string is too long.


$pos1 = strpos($bigString, '');
$pos2 = strpos($bigString, '
');
$resultingString = substr($bigString, -$pos1, $pos2);

You might have to add and/or substract some units from $pos1 and $pos2 to get the $resultingString right.
(if you don't have comments with tag1 inside of them sigh)


The right way:


Look up html parsers

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...