searching through a string

searching through a string

am 18.09.2006 05:25:48 von Ron Piggott

--=-QUNghOaajDo73DUZed0T
Content-Type: text/plain
Content-Transfer-Encoding: 7bit


If $file_name includes the path
/path/to/file/file_name.pdf
is there anyway of searching from the right hand side to the left and
getting the file name out the $file_name variable? The file name starts
the character following the last /

Ron


--=-QUNghOaajDo73DUZed0T--

Re: searching through a string

am 18.09.2006 05:38:50 von Chris

Ron Piggott (PHP) wrote:
> If $file_name includes the path
> /path/to/file/file_name.pdf
> is there anyway of searching from the right hand side to the left and
> getting the file name out the $file_name variable? The file name starts
> the character following the last /

http://www.php.net/pathinfo will do it for you.

If you can guarantee the filename is always on the end, you can use
basename (http://www.php.net/basename)

--
Postgresql & php tutorials
http://www.designmagick.com/

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

Re: searching through a string

am 18.09.2006 16:40:59 von Kae Verens

Ron Piggott (PHP) wrote:
> If $file_name includes the path
> /path/to/file/file_name.pdf
> is there anyway of searching from the right hand side to the left and
> getting the file name out the $file_name variable? The file name starts
> the character following the last /

this should do it.
$filename=preg_replace('/.*\//','',$filename);

Kae

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