Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Why bother with substr
in this case and look for the position of the occurrence of characters in the string? You can pull it out regularly without problems:
$str='
<header></header>
<p>content<p>
<footer></footer>';
preg_match('#</header>(.*?)<footer>#s', $str, $m);
$content = $m[1];
echo $content; /* <p>content<p> */
Find the coordinates of these occurrences, substitute ... But it's best to master regular expressions, they are much easier.
Something like this
$start = stripos($str, '</header>' ) + strlen('</header>');
$end = strripos($str, '<footer>');
$result = substr($str, $start, $end);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question