PHP search string

David Carr

Tutorials PHP & MySQL

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';
}

 

Copyright © 2006 - 2024 DC Blog - All rights reserved.