mixed strpos (string $haystack,mixed $needle [, int $offset = 0])
find the numeric position of the first occurrence of needle in the haystack string.
Parameters:
=> haystack: The string that is searched
=> needle :it is not a string.it is converted to an integer and applied as the ordinal value of a character.
=>offset: if specified,search will start this number of characters counted from the beginning of the string.offset is not negative.
find the numeric position of the first occurrence of needle in the haystack string.
Parameters:
=> haystack: The string that is searched
=> needle :it is not a string.it is converted to an integer and applied as the ordinal value of a character.
=>offset: if specified,search will start this number of characters counted from the beginning of the string.offset is not negative.
<?php
$string= 'abc';$find = 'a';$pos = strpos($
string
, $
find
);
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.if ($pos === false) {
echo "The string '$find' was not found in the string '$
string
'";
} else {
echo "The string '$find' was found in the string '$
string
'";
echo " and exists at position $pos";
}?>
No comments:
Post a Comment