Jump to content

Extract absolute path from URL


plexus

Recommended Posts

Hi all,

 

I've got the following HTML codes stored in a variable read off from some template tags:

 

<img alt="Image Title" title="Image Title" src="http://www.somedomain.com/photos/category/image_name.jpg" width="480" height="360" />

 

I would like to know how can I use PHP to extract out the absolute path of the src portion and assign it to a variable.

/photos/category/image_name.jpg

 

Thanks :)

Link to comment
Share on other sites

Not sure bout this coz im a complete newbie, but there's some sort of function that can check a number of characters from the start of a selected text, and also do the same for the end...and I'm guessing it could remove them also...if u know wat i mean.

 

Just had a look through my php stuff and here's wat I used in a file upload script, basically it checked the last 4 characters of the filename (.php, .exe etc etc).

 

(strcasecmp(substr("$file_name", -4), ".php") == 0)

 

Not sure if this is any help but just thought I would try and contribute :D

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.