Skip to content

strpos ​

php
number strpos (string $lancuch, string $znak )

Returns the numeric position of the first occurrence of $znak in $lancuch.

Example:

php
$mystring = 'abc';
$findme   = 'c';
$pos = strpos($mystring, $findme);


if ($pos === false) {
    print("String '$findme' was not found in '$mystring'");
} else {
    print("String '$findme' was found in '$mystring'");
    print(" at index: ".$pos);
}

Result:

String '$findme' was found in '$mystring' at index: 2