Skip to content
Advertisement

How to get the complete word of the character that is obtained with stripos()? (PHP)

I can’t find the documentation that indicates how to do it. I am dynamically displaying a part of a post description in the search results from my website.

Example:

JavaScript

Result:

JavaScript

I would like to be able to show “information” and not “formation”. Any suggestion?

Advertisement

Answer

Actually regular expressions work nicely for your particular problem. Search for w*formatw* using preg_match_all:

JavaScript

This prints:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement