I am using the following code that gets what is between <p>
and </p>
. Instead of displaying the result in an array how can I save every paragraph in a new variable ? Thank you!
I think that
foreach ($matches as $match) {
doSomething with $match[1];
}
should do the trick. $matches
should contain a list of each match, where a match consist of the whole string matched and then the groups. Since there is only one group in each match that you are interested, $match[1]
should give you the content of the paragraph, $match[0]
the whole paragraph with the <p>
tags on it.