Re: [PHP] getting a filename [with no extension] out of a url

2005-07-02 Thread Burhan Khalid

Richard Davey wrote:

Hello Graham,

Friday, July 1, 2005, 12:54:42 AM, you wrote:

GA if  $_SERVER['SCRIPT_NAME'] give this
GA /folder/folder/Library/php/filename.php

$_SERVER['SCRIPT_NAME'] won't give you that,
$_SERVER['SCRIPT_FILENAME'] would.

SCRIPT_NAME would just give you /filename.php

And if you need to remove the slash at the start, pick any of the
following: substr, str_replace, preg_replace, strpos, etc.


echo basename($_SERVER['SCRIPT_FILENAME'],'.php')

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] getting a filename [with no extension] out of a url

2005-06-30 Thread Graham Anderson

if  $_SERVER['SCRIPT_NAME'] give this
/folder/folder/Library/php/filename.php

what would be the proper way to strip the string until only 'filename' 
is left

I'm a bit new at eregi stuff

any help would be appreciated
many thanks

g

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting a filename [with no extension] out of a url

2005-06-30 Thread Tom Rogers
Hi,

Friday, July 1, 2005, 9:54:42 AM, you wrote:
GA if  $_SERVER['SCRIPT_NAME'] give this
GA /folder/folder/Library/php/filename.php

GA what would be the proper way to strip the string until only 'filename'
GA is left
GA I'm a bit new at eregi stuff

GA any help would be appreciated
GA many thanks

GA g


I do this:
$file = '/folder/folder/Library/php/filename.php';
$ext = @substr($file, (@strrpos($file, .) ? @strrpos($file, .) + 1 : 
@strlen($file)), @strlen($file));
$fname = basename($file,$ext);

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting a filename [with no extension] out of a url

2005-06-30 Thread Richard Davey
Hello Graham,

Friday, July 1, 2005, 12:54:42 AM, you wrote:

GA if  $_SERVER['SCRIPT_NAME'] give this
GA /folder/folder/Library/php/filename.php

$_SERVER['SCRIPT_NAME'] won't give you that,
$_SERVER['SCRIPT_FILENAME'] would.

SCRIPT_NAME would just give you /filename.php

And if you need to remove the slash at the start, pick any of the
following: substr, str_replace, preg_replace, strpos, etc.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I do not fear computers. I fear the lack of them. - Isaac Asimov

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php