yugnats
02-01-2006, 11:42 PM
I am trying to take a string like this:
/php/txtDB/txt-db-api/examples/articles.php
and I need to be able to take 'articles.php' off the end and assign it to a variable.
i looked at rtrim in the PHP.net manual but can't figure out how to use it. any help or direction would be appreciated.
thanks, yug
yugnats
02-02-2006, 01:52 AM
I am trying to take a string like this:
/php/txtDB/txt-db-api/examples/articles.php
and I need to be able to take 'articles.php' off the end and assign it to a variable.
i looked at rtrim in the PHP.net manual but can't figure out how to use it. any help or direction would be appreciated.
thanks, yug
actually, i need to just take 'articles' out and assign it to a variable.
Burhan
02-02-2006, 02:26 AM
You need pathinfo (http://php.net/pathinfo) and basename (http://php.net/basename)
$path = '/php/txtDB/txt-db-api/example/articles.php';
$parts = pathinfo($path);
$filename = basename($parts['basename'],'.'.$parts['extention']);
yugnats
02-02-2006, 12:19 PM
You need pathinfo (http://php.net/pathinfo) and basename (http://php.net/basename)
$path = '/php/txtDB/txt-db-api/example/articles.php';
$parts = pathinfo($path);
$filename = basename($parts['basename'],'.'.$parts['extention']);
great, thanks alot, i'll try it out later:)