Answer the question
In order to leave comments, you need to log in
Why does the regular expression only find the last match?
Hi friends.
I'm trying to pull out the text of the links that are in the cells of the table. But preg_match_all gives me only the last match, but I need the whole list.
$content = '<tr>sdf<td><a class="123">777777</a></td><td></td><td><a class="123">888888</a></td></tr>';
$pattern = '~<td><a.*>([0-9]{5,})<\/a><\/td>~mui';
preg_match_all($pattern, $content, $matches); // находит только 888888
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question