Black Friday sale is now on! 50% off Laravel: The Modular Way. Learn more

PHP search string

David Carr

PHP & MySQL Tutorials

    Here's a quick way to search for a word inside a string, using strpos the string to look at and the word to look for. Upon a match, true is returned.

    $string = '';
    if (strpos($string, 'api') !== false) {
        echo 'true';


    Laravel Modules Book by David Carr

    Help support the blog so that I can continue creating new content!

    Subscribe to my newsletter

    Subscribe and get my books and product announcements.

    © 2009 - 2022 DC Blog. All code MIT license. All rights reserved.