RE: [PHP] Displaying first 100 characters of an article
| From: | Lawrence dot Sheed at dfait-maeci dot gc dot ca | Date: | Tue, 03 Oct 2000 07:30:40 +0000 |
| Subject: | RE: [PHP] Displaying first 100 characters of an article | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18377@lists.php.net to get a copy of this message | ||
How about:
$stuff = "my long string here";
if (strlen($stuff)<100) {
$retstring = $retstring . $stuff;
}
else {
$retstring = $retstring . substr($stuff,0,100) . "...";
}
cheers,
Lawrence.
-----Original Message-----
From: Ben Weinberger [mailto:ben@digitalsmiths.com]
Sent: October 3, 2000 03:27 PM
To: php-general@lists.php.net
Subject: [PHP] Displaying first 100 characters of an article
Hi~
I'm pulling data out of a MySQL db and displaying it on a web page... the
data is like a news article with a title and a body. Currently, I can
display the title and I have it linked to a javascript pop-up window that
displays the full article. I would like to add the first 100 characters of
the article under the title as well... something like follows:
Version 6.0 just Released
We've worked hard to bring you a new and improved version 6.0 software
package so that you....
Is there a way to make those words under the title appear and only display
the first 100 characters followed by a "..."?
Thanks,
-Ben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net