How to search text in string using php ?

php
search
string search

Suppose I have string below,

$text = "Hello World!";

By using below code to get string position. By using string position we can check/search in a given string.

if (strpos($text, 'World') !== false) {
    echo 'true';
}

Basically the expected ouput is "true".

Note that the use of !== false is deliberate. The strpos() function finds the position of the first occurrence of a string inside another string.

You might also like:

Functions in javascript

25-05-2018 functions javascript es5 es6 arrow functions named functions Closures Nested Functions Callbacks Arrow functions.

Detect AdBlock with JavaScript in my browser

30-07-2017 AdBlock javascript detect

How to redirect one page to another page in php

20-03-2017 redirect php

Sanitization in java sript

14-03-2017 sanitization java script

Remove last two characters from given string

06-03-2017 substring javascript remove