Organizational Research By

Surprising Reserch Topic

Difference between strpos and stripos in php?



asked Sep 13, 2013 in PHP by ashish singh
edited Sep 12, 2013
0 votes
68 views



Related Hot Questions

1 Answer

0 votes
Difference between strpos and stripos in php
 
 
strpos()Function in PHP:
 
strpos():Returns the position of the first occurrence of a substring in a string.
If the string is not found, this function returns FALSE.
 
Strpos Syntax:
strpos(string,search,start)
 
Strpos() function example in php:
$phpString = 'strpos function in php';
$search   = 'function';
$position = strpos($phpString, $search);
 
 
if ($position !== false)
{
     echo "Found at position $position";
}
 else
{
     echo "Not Found";
}
?>
 
stripos() Function in PHP:
 
The stripos() function is case-insensitive. 
stripos():Returns the position of the first occurrence of a case-insensitive substring in a string.
If the string is not found, this function returns FALSE.
 
stripos Syntax:
stripos(string,search,start)
 
stripos () function example in php:
$phpString = 'strpos function in php';
$search   = 'Function';
$position = stripos($phpString, $search);
 
 
if ($position !== false)
{
     echo "Found at position $position";
}
 else
{
     echo "Not Found";
}
?>
 
Difference between strpos and stripos in php:
stripos works in php5, strpos in php4 and php5.
Unlike the strpos(), stripos() is case-insensitive.
answered Sep 13, 2013 by ashish singh
edited Sep 12, 2013

...