Re: note 27931 added to function.substr
| From: | Jesus M. Castagnetto | Date: | Thu, 26 Dec 2002 06:24:42 +0000 |
| Subject: | Re: note 27931 added to function.substr | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-41296@lists.php.net to get a copy of this message | ||
Joao,
Perhaps you are not aware of basename() which does
what your code attempts. I added an editor's note to
yours. Let me know if you want your note re-edited or
removed.
--- joaobett@oninet.pt wrote:
> /********************************************
> Getting the file name from an address
> like http://www.xpto12345.xyz/abc/def/ghi.php
> using substr() function
> ********************************************/
>
> // This procedure only works when the filename
> // is at the end of the string
>
> $fn="abc/def/ghi/jkl.php"; // 'where is the
> filename' string
>
> $a = strlen("$fn");
>
> while ($a>0){
> if(substr(substr($fn, $a, strlen($fn)), 0,
> 1)=="/"){break;}
> $b=substr($fn, $a, strlen($fn));
> $a=$a-1;
> }
>
> print $b;
> --
> http://www.php.net/manual/en/function.substr.php
>
http://master.php.net/manage/user-notes.php?action=edit+27931
>
http://master.php.net/manage/user-notes.php?action=delete+27931
>
http://master.php.net/manage/user-notes.php?action=reject+27931
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto <jmcastagnetto@php.net>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com