Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-05-2011, 01:19 PM   PM User | #1
YourDirector
Regular Coder

 
Join Date: Jul 2011
Posts: 116
Thanks: 6
Thanked 0 Times in 0 Posts
YourDirector is an unknown quantity at this point
Removing part of a var

Hi there,

I have a var which will be something like:

"./xml/filename.xml"

I need a way of later cutting down this the "./xml/" from this var so it is simply:
"filename.xml"

Is this possible?

Thanks
YourDirector is offline   Reply With Quote
Old 09-05-2011, 01:47 PM   PM User | #2
YourDirector
Regular Coder

 
Join Date: Jul 2011
Posts: 116
Thanks: 6
Thanked 0 Times in 0 Posts
YourDirector is an unknown quantity at this point
Never mind, Noob here hadn't used explode before. Thanks all.
YourDirector is offline   Reply With Quote
Old 09-05-2011, 01:48 PM   PM User | #3
Chris Hick
Regular Coder

 
Join Date: Oct 2010
Location: Florence, MS
Posts: 476
Thanks: 10
Thanked 33 Times in 32 Posts
Chris Hick is an unknown quantity at this point
Well, you could use the str_replace function in php.

PHP Code:
$remove './xml/';
$filename './xml/filename.xml';
$newfilename trim(str_replace($remove,' '$filename)); 
__________________
Notice: If you post a problem and it gets fixed, please remember to go back and place it as solved. ;)
I always recommend the HEAD First series of books for learning a new coding language. ^_^
Chris Hick is offline   Reply With Quote
Old 09-05-2011, 02:08 PM   PM User | #4
dolrichfortich
New Coder

 
Join Date: Aug 2010
Location: At home with my bunny sleepers.
Posts: 27
Thanks: 0
Thanked 7 Times in 7 Posts
dolrichfortich is an unknown quantity at this point
If all values of your variable is a valid file path, you can just use basename

PHP Code:
echo basename('./xml/filename.xml'); //should return filename.xml 
__________________
Choose a job you love, and you will never have to work a day in your life.

Dolrich Fortich Love to Code Using :)
[PHP/MySql, Jquery, Codeigniter, Opencart]
dolrichfortich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.