the last word of a string??
| From: | zerosumzero@yahoo.com | Date: | Sat, 18 Aug 2001 05:40:40 +0000 |
| Subject: | the last word of a string?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62292@lists.php.net to get a copy of this message | ||
So I opened a file like this:
$filename ="text.txt";
$fh = fopen($filename, "r");
then I get the last line of the file like this:
while (!feof ($fh)) {
$lastline = fgets($fh, 4096);
}
now I want the last word of $lastline ... how do I do this? I've been
trying all kinds of things but nothing seems to be what I need.
I would also like to be able to get the last X words of $lastline?
so if
$lastline = "I am a newbie"
I get: "am a newbie"
Help!
--
susan@futurebird.com
http://futurebird.diaryland.com