hi all, does anybody know how to retrieve current php file name or html file name and get the last 3 character
for example, http://www.help.com/ACD10809.html
i would like to get the "809" character using php or other language ?
does anybody ?
hi all, does anybody know how to retrieve current php file name or html file name and get the last 3 character
for example, http://www.help.com/ACD10809.html
i would like to get the "809" character using php or other language ?
does anybody ?
Well, the magic constant FILE should give you the path to the current file. [man]basename/man on that will give you just the filename. [man]strrpos/man will tell you where the last period/dot is in the file name. Finally, [man]substr/man will give you the three characters before that dot (just subtract 3 from the dot's location and use a length of 3).
EDIT: I suppose you don't really need to use [man]basename/man at all, really.
If using PHP 5.2+:
$last3 = substr(pathinfo(__FILE__, PATHINFO_FILENAME), -3);
amazing
It's funny, as soon as I saw the GMail preview "Dear bradgrafelman, NogDog has just replied to a thread you have subscribed to entitled - read current file name" text pop up in the corner of my screen, I instantly thought "Dang, I bet he suggested using [man]pathinfo/man" (yes, my internal thoughts/exclamations come complete with clickable manual links). :p