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:

Use java script file client side and server side at a time in node js

30-07-2017 node js include call javascript

How to use http-post request in node js

14-03-2017 http-post module node js

How to convert html to pdf in Node js

12-03-2017 pdf convert html node js

Remove last two characters from given string

06-03-2017 substring javascript remove

Filters for convert text to camel case in Angular Js

05-03-2017 angularjs camelcase filters