Posted by Bob Stearns on 11/16/05 05:35
Jonathan wrote:
> I have a project I am working on and I have a field in my description
> for the description of the cars and I am using a system that uses html
> templates driven by php/xml so I would need to wrtie them script in the
> html template...
>
> How do I limit the amount of words displayed.... and does these worked
> include numbers or how are number handled ? because there might be
> numbers as its a description of a muscle car...
>
> Please give me some advice or point me in the right direction...
>
Define "word" as characters between blanks. Then the following untested
code is an approximation to a solution to your problem.
Retrieve your description into $desc
$words = explode($desc, " ", $maxwords);
if(count($words)>=$maxwords) {
$words[$maxwords] = "";
$short_desc = implode(" ", $words)
}
else $short_desc = $desc;
Navigation:
[Reply to this message]
|