I need to subdtring a paragraph in php, without breaking a word?

Recommended Answers

Be more explicit. Would be nice if you give an example.

Jump to Post

All 4 Replies

Be more explicit. Would be nice if you give an example.

Use a loop. Start at the maximum length of your string. Check if it's a space (or non-word char). If it's not, go back one position and check again. Stop when the current character is a space (or another non-word character).

Member Avatar

is this homework? smells like it. either way show us what you've tried so far

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.