I’ve been looking around and haven’t been able to find anything. I would like to truncate a string without cutting a word short. Like an excerpt.
$string = "This is my string"
9 = "This is m"
Ideally would like "This is my"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Should do what you want, i.e. it starts at the character number you give it, looks for the next space, and cuts the string short there.