View Single Post
Old 12-05-2003, 11:16 AM  
4Pics
Confirmed User
 
Industry Role:
Join Date: Dec 2001
Posts: 7,952
Quote:
Originally posted by fletcher
I'll be nice and share one regexp

This grabs all linked images on a page:

PHP Code:
/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im 
In PHP, do it like this:

PHP Code:
preg_match_all("/<a.*href=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><img.*src=[\"|\']([^\"|^\'|^\s]+)[\"|\'].*><\/a>/im"$string$matches
$matches is an array with all of the images with links. Just change up the regexp for plain links, images, etc.
Thanks, but is your top link correct? It looks like it is cutoff?
4Pics is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote