How to return only part of a feild from database using php substr but to take into account spaces I 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.
Trending right now
Hide How do I unblock someone on facebook Council tax letter template after receiving a summons How to send a postal cheque to lloyds bank plc How to return only part of a feild from database using php substr but to take into account spaces Weird fish salmon pink hoody size l it is a bit bobbly otherwise good condition Acts are not laws Why No One Should Ever Verify Their Details on Any Website Visited link to remain same colour How to unblock a plug hole in your bath Why do people actually sell on ebay How to remove item specifics on ebay Why are the vaccinated not actually vaccinated How to make a million pounds Why Mastering One Skill Is Your Fastest Path to Financial Success Html apostrophe single quote quote mark Should I take the covid Vaccine Twitter friends diet tips Does eating eggs increase your risk of diabetes How to cure earache quickly and easily Join the silent protest Potty Train your baby from 6 months old Potty Train your baby from 6 months old Natural Remedies and Dietary Approach for Psoriasis How do I block someone on facebook How to stop bank scammers over the phone quickly and easily Back magic instructions How to cut your electricity bill in half for the price of a phone call. How to get scammers off the phone and have some fun Cease and desist letter to send to the bailiffs to stop them collecting council tax How to get your child into rainbows brownies guiding scouts beavers when there is a waiting list How to teach your child to swim easy lessons anyone can do How does the covid vaccine protect others Are you a commercial electrical company What is the difference between Jam and peanut butter Joke on how i met your mother If not paying council tax was unlawful.... Removing hairs from your ears using depilatory creams that are available in the market. How do i edit a facebook album name in a group Vodka Christmas cake recipe How to get more customers Boost your business Promote your site here for free Ebay fraud what can you do
|