Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

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

 

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

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

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.