I'd like to be able to pull the first X words from a database field for use in a preview. Basically if a field 's content was
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris malesuada."
I would like to echo
"Lorem ipsum dolor sit amet... see more"
What's the best way to do this?
The only thing I know to do is pull the whole field in a query then do something like
$foo = [query_results];
$bar = explode(' ', $foo);
for($x=0, $x<6, $x++){
echo $bar[$x];
};
echo "... see more"
Is there a better approach to this?