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
Share on other sites

Just an update... I have successfully used the substr() function the remove the first part... although that will only work as long as the front page remains constant. It works for now, anybody have any other ideas for in the future?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.