How to find the text in string using PHP

Hi guys here I am going to share how to find a text inside a particular given string by using PHP

here is the code

$string_t0_search = “PHP”;
$paragraph = “I love writing PHP code.”;

if(strstr($paragraph,$string_to_search)) {
echo “found it.”;
} else {
echo “not found.”;
}

strstr() is php function used to  seasrch for the first occurrence of a string inside another string.

You May Also Like

Never Miss Any Web Tutorials, Guides, Tips and Free eBooks

Join Our Community Of 50,000+ Web Lovers and get a weekly newsletter in your inbox

 

I hate spam too. Unsubscribe at any time.

3 thoughts on “How to find the text in string using PHP”

Leave a Comment