Hi,
Im needing some help with cutting a string but not halving the last word. i know to use substring but if it lands in the middle of a word it just gets halved.
i was trying this but it does not seem to work.
function cutTheString( $stringIn , $length ){
$stringOut = '' ;
// FIRST CUT IT
$stringOut = substr( $stringIn , 0 , $length ) ;
// NOW TAKE OFF THE LAST WORD
$needle = " ";
//find length of the needle
$needle_len = strlen($needle);
//find postion
$position_num = strpos($stringOut,$needle) + $needle_len;
//cut the string
$result_string = substr("$stringOut",0,$position_num);
return $stringOut ;
}
I hope you can help me,
thanks,
David