RE: [PHP] Splitting Text
| From: | Matthew Loff | Date: | Mon, 06 Aug 2001 21:37:36 +0000 |
| Subject: | RE: [PHP] Splitting Text | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-61500@lists.php.net to get a copy of this message | ||
You can do this several ways... Either use explode():
http://www.php.net/manual/en/function.explode.php
...to split the retrieved data by a space " " as the delimeter, then use
a for() loop to print X number of words... E.g.:
$array = explode(" ", $db_string);
for($i = 0; $i < 25; $i++)
echo $array[$i];
(That will print the first 25 words...)
Or, another way to do it is to use strtok() to tokenize the string...
http://www.php.net/manual/en/function.strtok.php
The manual has a good example of tokenizing a string into individual
words...
-----Original Message-----
From: Jordan Elver [mailto:jord.elver@virgin.net]
Sent: Monday, August 06, 2001 5:20 PM
To: PHP General Mailing List
Subject: [PHP] Splitting Text
Hi,
Can anyone give some pointers for my problem.
I want to pull articles out of a db and then show the first x number of
words
with a read more link to the rest of the article.
Could someone point me in the right direction. I've seen a code snippet
for
this, but now I can't find it :-(
TIA,
Jord
--
Jordan Elver
http://www.jordanelver.co.uk
Oops, my brain just hit a bad sector!
--
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