How to search text in string using php ?

29-10-2017 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 id by using name attribute in javascript
20-03-2017 html id name javascript
Navigate to another page using java script
06-03-2017 javascript redirection navigation
Filter for change Date format (MM-dd-yyyy HH:mm) in Angular Js
05-03-2017 mm-dd-yyyy HH:MM date formats angular js
How to get drop down value when drop down change using javascript
27-02-2017 onchange events dropdown javascript functions
Sample Validations in javascript
22-02-2017 validations javascript