473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Taking part of a URL

Hey everyone,
I am confused by how to get a script to take a chunk out of a URL. I was reading here, and found a solution that was close to what I need, but not exact.

That ereg_match will result in
Expand|Select|Wrap|Line Numbers
  1. /word-word-word/word-word-word.html
Now when you can live with that, you can find what you want using PHP, as sample:
[php]
$text='http://www.website.co.uk/word-word-word/word-word-word.html';
preg_match_all("/^(https?:\/\/)?([^\/]*)(.*)/i", "$text", $matches);
echo dirname($matches[3][0]);[/php]
That will give you
Expand|Select|Wrap|Line Numbers
  1. /word-word-word
Ronald
I need something close to that, but what I need it to do is to be able to take the end of the URL, not the middle. What I'm trying to to is get it to take the end of the URL, so that I can provide a direct link to it from the script to delete the old file. The extension will vary from .jpg/.png/.gif, so I need to make sure that is able to continue to vary, too. Can anyone help with this?

Thanks a ton in advance!
Aug 10 '08 #1
1 1135
pbmods
5,821 Expert 4TB
Heya, DriveN.

Check out basename() (http://php.net/basename).
Aug 10 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: djc | last post by:
the aspnet_wp.exe process in taking up lots of memory. Right now just the one main page loads and imediately goes to the top of the memory usage list with around 32MB of memory usage. The page only...
1
by: batista | last post by:
Hello all, I have made a dotnet windows application which is taking a lot of cpu time....and memory as well. Now, i want to know if there is any tool which can find out which part of code is...
13
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
6
by: mdh | last post by:
Hi All, I understand atof is in the library, but this is part of my learning curve. Given double atof( char *s){ double d = 0.00; double sign = 1.00; double fractprt = 1.00;
6
by: billyusa | last post by:
Hello all, im taking a intro to c++ class as part of my design comm, and having issues withthe codelab part (online). First off it doesnt give any help to what you are doing wrong. the prob is: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.