How to return only part of a feild from database using php substr but to take into account spacesI recently needed to get data from a mysql data base but only wanted to return the first 35 characters, but did not want it to cut off in the middle of a word so wanted to make sure that it checked for a space after that and cut off after that space.
Firstly though I had to check that there were enough characters otherwise it would return a false, also if the cutoff point was the last word it would also cut off as it would not find a space, so would return a blank, so in both cases I used the original text as that was fine.
Otherwise it then used the formula below, change len to be the number of characters you want to return. If you have a set number and cant exceed that number just make your $len about 15 lower than you want that should always return less.
CAN YOU HELP
Turbo Charge your businessWe put our money where our mouth is. Our mission is to help any business anywhere get back on track.
If we don't bring you new customers you pay us nothing. We take nothing up front and there is no contract. We trust you implicitly. And it is literally if you don't pay us for bringing in new customers, then we stop brining them in.
You decide how much you are willing to pay for a customer and you pay once we bring them to you.
Simple, easy nothing else to explain.
If you would like us to help you get your business or products booming email us at email@example.com