Tag: Ring POS class starts start return function Art font
- Strpos () -finds the position of the first occurrence of a string in another string (case-sensitive)
- Stripos () -finds the position of the first occurrence of a string in another string (case insensitive)
- Strrpos () -finds the last occurrence of a string in another string (case-sensitive)
- Strripos () -finds the last occurrence of a string in another string (case insensitive)
Parameters:
Strripos (string,find,start)
string: Required. Specifies the string to search for.
find: Required. Specifies the character to find.
start: Optional. Specify where to start the search.
Example:
#
<?php
$str = ' abcdef ';
$find = ' abc ';
$pos = strpos ($mystring, $findme);
// Note that this is used === cannot use = =
// because if not
The string returns False if the string is at the beginning of the string and returns 0 in order to differentiate between 0 and false, you must use the equivalent operator = = = or! ==
if ($pos === false) {
echo "$find not in $str";
} else {
echo " $ find
In $ str
";
}
?
< Span class= "example-contents" >2#
<?php
$string = ‘abcdef abcdef‘;
$find = strpos($string,‘a‘,1); // $find
= 7, 不是 0
?>
Determines whether a character is in a string in PHP