How to check string in string variable using php

PHP tutorial, we will show you how to check string in php variable using php language. This easy very easy using php language. we given code snippet.

Use can use the strpos function for string to search in

$mystring = 'abc xyz';
$findme&nbsp;&nbsp; = 'abc';
$check_string = strpos($mystring, $findme);

// because the position of 'a' was the 0th (first) character.
if ($check_string === false) {
 echo "The string '$findme' was not found in the string '$mystring'";
} else {
 echo "The string '$findme' was found in the string '$mystring'";
 echo " and exists at position $pos";

Add a Comment

Your email address will not be published. Required fields are marked *