How to search text in string using php ?

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:

Convert and download html to pdf without saving file

28-10-2018 node js convert html to pdf pdf download pdf without saving

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

30-07-2017 node js include call javascript

Time Sorting Ascending or Descending Order in Javascript

19-07-2017 Javascript ascending order descending order

How to set or update or push the values into Object in javacript

27-02-2017 javascript set update push object

Sample Validations in javascript

22-02-2017 validations javascript