Jump to content

Grabbing IMG Tag (Advanced)


drath

Recommended Posts

Wasn't really sure what to title the thread, and I think this is where this type of post would go:

 

I'm not the greatest with PHP but i've already got the part where I can create a nice string with the source code from a page (using snooper). Now, I'm having a problem grabbing the IMG tag properly. And yes, I am using preg_match_all (for an array) and this code as it is now:

 

$pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/'; 

 

This normally would work, but in this "advanced" case, I need to also remove the first instance of the http://, which may be utilizing the function "substr", but so far I have been unsuccessful.

 

To illustrate, this is the string I now get:

 

http://domain.com?h?:=http://realimage.com/realone.jpg

*I bolded the middle part as it may be important in removing the first half.

 

As you can see, I will need to strip the first part somehow, either using preg_match or somehow dynamically using substr. This is a little over my head :), so I need a little bit of help from you "freaks", haha.

 

Link to comment
https://forums.phpfreaks.com/topic/115555-grabbing-img-tag-advanced/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.