PHP & MySQL | Tutorials

David Carr

PHP search string

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 = 'https://api.domain.com/files';

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

 

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

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