Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

getting filename and ext of URL

0 views
Skip to first unread message

Steven MysticFallout

unread,
Mar 31, 2003, 11:53:49 PM3/31/03
to
how could i strip the file name plus extension from a URL?

i want to take a url like

http://www.domain.com/theimage.jpg

and put theimage.jpg into a variable.

thanks for any help/advice.


Jan Pieter Kunst

unread,
Apr 1, 2003, 12:01:13 AM4/1/03
to
In article <b6b66p$9c9$1...@ins22.netins.net>,
"Steven MysticFallout" <winter...@hotmail.com> wrote:

> how could i strip the file name plus extension from a URL?
>
> i want to take a url like
>
> http://www.domain.com/theimage.jpg
>
> and put theimage.jpg into a variable.

I think basename() should do what you want. Check the docs to be sure.

JP

--
Sorry, <dev...@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.

PoDuck

unread,
Apr 2, 2003, 5:58:36 AM4/2/03
to
I guess that would work too. I tend to like playing with regex. Anyway,
the regex way I would use is:

preg_match('/^.*\/(.*)/', $url, $patharr);

$patharr[1] would hold the filename.

Anyway, that's just academic since the basename() does exactly what you
need. I just put it here to keep my regex good.


"Jan Pieter Kunst" <dev...@cauce.org> wrote in message
news:devnull-7BFC44...@news1.news.xs4all.nl...

0 new messages