[EMAIL PROTECTED] (Mike Gifford) writes:

> Hello,
> 
> I'm trying to replace a couple of lines of code:
> 
>       $dotpos = 1 - (strlen($userfile_name) - strpos($userfile_name, '.'));
>       $extension = substr($userfile_name, $dotpos);
> 
> with a simpler regular expression:
>       $extension = eregi_replace( "/.*", "", $userfile_name);
> 
> However it isn't working..
> 
> What I'd like to do is to find the extension of a file name and place
> that in a variable.  So in '/home/mike/test.txt', I want to have the
> statement return 'txt'

you don't need a regular expression for that...

$extension = strrchr(basename($userfile_name), '.');

  -robin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to