question for string?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mapperkids
Forum Newbie
Posts: 15
Joined: Mon Feb 11, 2008 8:53 pm

question for string?

Post by mapperkids »

Hi,

I have a string like this

"c:\Directory1\Directory2\Directory3\filename.zip"
"c:\Directory1\filename.zip"
"c:\Directory1\Directory2\Directory3\Directory4\filename.zip"


I want to extract only the "filename.zip" part to a variable. how can i do that.

Thanks,
Johnny
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: question for string?

Post by pickle »

You could try basename(), or explode(), or a combination of strrpos() and substr()
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mapperkids
Forum Newbie
Posts: 15
Joined: Mon Feb 11, 2008 8:53 pm

Re: question for string?

Post by mapperkids »

pickle wrote:You could try basename(), or explode(), or a combination of strrpos() and substr()
Problem solved by using the Basename() function.
Thanks!
Post Reply