Re: A way to select first 15 words from a string
From: Stuart (stuart_gibson_at_hotmail.com)
Date: 01/18/04
- Next message: paul schroeder: "Re: A way to select first 15 words from a string"
- Previous message: Stuart: "Re: Can't get extension directory recognized"
- In reply to: paul schroeder: "A way to select first 15 words from a string"
- Next in thread: paul schroeder: "Re: A way to select first 15 words from a string"
- Reply: paul schroeder: "Re: A way to select first 15 words from a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 18 Jan 2004 11:17:30 -0000
"paul schroeder" <paulie@hotmail.com> wrote in message
news:400a417b.51741236@News.CIS.DFN.DE...
> Is there a function to select a number of words from a string, say
> first 15?
>
> I can't find one and I thought I should ask before I start wrting some
> script to do it.
>
> If the answer is NO, there is a second question:
>
> If there is no function to do it, do you think it is ok to implode the
> string and then just count out the first 'x' number of words you want?
>
>
> Or is there a better way?
>
> Thanks in advance.
PHP's substr() function does exactly what you need:
Code below is from PHP Manual
(http://uk.php.net/manual/en/function.substr.php)
<?
$rest = substr("abcdef", 1); // returns "bcdef"
$rest = substr("abcdef", 1, 3); // returns "bcd"
$rest = substr("abcdef", 0, 4); // returns "abcd"
$rest = substr("abcdef", 0, 8); // returns "abcdef"
?>
It seems easy enough to get working.
- Next message: paul schroeder: "Re: A way to select first 15 words from a string"
- Previous message: Stuart: "Re: Can't get extension directory recognized"
- In reply to: paul schroeder: "A way to select first 15 words from a string"
- Next in thread: paul schroeder: "Re: A way to select first 15 words from a string"
- Reply: paul schroeder: "Re: A way to select first 15 words from a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|