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
https://forums.phpfreaks.com/topic/56804-extract-absolute-path-from-url/
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

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.