The following function is for to take a definite number of words from an string:
function take_definite_number_word( $words = 10)
{
$wordCount = count(explode("",$item->description)); // count by space
if ($wordCount<$words)
{
$adjustedText = $item->description;
}
else
{
$adjustedText = implode(" ", array_slice(explode(" ",$item->description), 0, $words));
}
}
function take_definite_number_word( $words = 10)
{
$wordCount = count(explode("",$item->description)); // count by space
if ($wordCount<$words)
{
$adjustedText = $item->description;
}
else
{
$adjustedText = implode(" ", array_slice(explode(" ",$item->description), 0, $words));
}
}
No comments:
Post a Comment