You can use the PHP strpos()
function to check whether a string contains a specific word or not.
The strpos()
the function returns the position of the first occurrence of a substring in a string. If the substring is not found it returns false
. Also note that string positions start at 0, and not 1.
Let's check out an example to understand how this function basically works:
<?php
$word = "find";
$mystring = "how to find char from string in php";
// Test if string contains the word
if(strpos($mystring, $word) !== false){
echo "Yes found that";
} else{
echo "Not Found!";
}
i hop it can be help lot.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Laravel 8 get all Files in Directory Example
You may want to get images from server a...How to convert a string to lowercase in PHP
Use the PHP strtolower() funct...Twitter API OAuth 2.0 Authorization Example
Twitter is one of the most powerful soci...How to Generate QR Code in Laravel 8
QR(Quick Response) code is a type of bar...How to Set CSS background-image Property Using jQuery
Use the jQuery CSS() Method To set th...