How to check string in string variable using php

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

<?php
$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";
}
?>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.