0
I would like to display only part of a String that contains a text. Make a "Click to read more", I tried with
substr
but since I don’t know what character a word ends in, he cuts the text in the middle of the words, I wanted him to cut the text but leave the words whole. I tried to make
explode()
and take a part only and then
implode()
but that didn’t work because it got all messed up the text. If anyone can help. My site is using Laravel PHP
Idea: you can use substring, but you have to find out where the word ends. You can think of a function like "I want about 200 characters, if in the 200th character I’m in the middle of a word, take a little more characters until you get to the end of the word and return me the index of that". With this index you can call to subst. Maybe you find the
regex
useful for this, but need not.– rodorgas