September 9th, 2000, 08:27 AM
I have been looking through some of my PHP books and through this forum.
I have determined that I can chop off my body for use as a document summary using the $body=substr($body, 0, 150) function.
My question is...
What can I add to have the summary cutoff at the nearest period?
Example of bad solution:
"Joe Schmo, the director of city development, announced his plans on what the city plans to do abo"
Example of what I would like to do:
"Joe Schmo, the director of city development, announced his plans on what the city plans to do about pollution in the new waterway."
How can I go about setting the string to be cutoff at a "."(period)
September 9th, 2000, 08:58 AM
you can do that,if you don't want get cutoff after a certain length then try this..
$variable="Joe Schmo, the director of city development, announced his plans on what the city plans to do abo";
//seperate the string based on comma and put it in $values array.
echo "summary : $values";
//print the first portion...
www.jobxyz.com-IT Career Portal
"The fear of the LORD is the beginning of knowledge..."
[This message has been edited by Shiju Rajan (edited September 09, 2000).]
September 9th, 2000, 09:56 AM
You could also use strtok()...
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$string = "Hello there. What are you doing? I'm not doing anything.";
$tok = strtok($string,".");
echo $tok . "<br>";
This will echo out "Hello there." (Or, at least it should. )
To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson