I need to find all the image html tags that are included in a page using PHP regular expressions
Example
<img src="images/image.jpg" />
My code
preg_match('/<img src=\"images\/.*/',$tags,$matches);
The strange thing is it only finds the first occurence, not the rest of the tags in the page
Use preg_match_all
. preg_match
only finds the first occurence, while preg_match_all
finds all occurrences of the pattern.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.