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:

How to get current date and time (yyyy-mm-dd H:i:s) using javascript

09-03-2017 javascript date time

Filter for change Date format (MM-dd-yyyy) in Angular Js

05-03-2017 mm-dd-yyyy date formats angular js

How to change background color and color to the text using javascript

27-02-2017 css javascript colors

How to get drop down value when drop down change using javascript

27-02-2017 onchange events dropdown javascript functions

Get Unique values from array/object in javascript

19-02-2017 javascript unique remove repeated values from array