Re: Splitting Text
| From: | Jordan Elver | Date: | Tue, 07 Aug 2001 13:48:41 +0000 |
| Subject: | Re: Splitting Text | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-61564@lists.php.net to get a copy of this message | ||
Thanks for that. I ended up using your method as using the LEFT function in a
SELECT only grabs characters.
Cheers,
Jord
On Monday 06 August 2001 17:37, you wrote:
> 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
Web Developer
The InternetOne UK Ltd