How to use strpos function in PHP

PHP

We will show you a simple example which will show you how to find the string position in php. There are two parameters used in the strpos function. First parameter will be the complete string and second parameter will be the search string. Suppose my Name is “ABCDEF” and i want to find the position of “D” , then this function is used . You can check the example and you can try and use in your php file .

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>String Position Example in PHP</title>
</head>
<body>
<?php
//This is the Simple example with the string variable you can get the string position
$name = "ABCDEFGHIJKL";
echo strpos($name,'D');
//The Result will be 3 starting with 0 the position of D is 3
echo '<br>';

$data = "This is the Testing String to check the string Position.";

$chk = 'check';
//We will search the position of word "check"
echo strpos($data,$chk);

// The Result will be 30 starting with index as 0
?>

</body>
</html>
-->