简体   繁体   中英

PHP strpos and strlen

I'm trying to get words before and after a string in a $body thats taken from a mysql entry. I'm able to find the keyword in the body, get its strpos and its strlen. From there I believe I should be able to tell it to print X characters (or ideally words) before and after that but I can't seem to find anything on google telling me HOW. Is there a PHP function that tells it to start at $strpos and then somehow use the strlen and print before and after that?

Hope that wasn't too unclear, any help is appreciated - thanks. I got the original strpos and strlen idea from Amandas answer here: Return words before and after the first occurrence of a string

But I don't understand how to apply that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM