PHP Programing language

strpos() Functions in PHP
Previous Home Next
adplus-dvertising

stripos()

The stripos() function finds the position of the first occurrence of a string inside another string. stripos() function is case-insensitive.

Syntax:
stripos(string,find,start)

Example:

<?php
echo stripos("Hello India..!!, Gud Morning","Morning");
?>

Output:

21

strpos()

The strpos() function finds the position of the first occurrence of a string inside another string. strpos() function is case-sensitive.

Syntax:
strpos(string,find,start)

Example:

<?php
echo strpos("Gud Morning...!!, Gud morning India","morning");
?>

Output:

22

strripos()

The strripos() function finds the position of the last occurrence of a string inside another string.

Syntax:
strripos(string,find,start)

In above syntax, "string" specifies the string to search, "find" specifies the string to find and "start" specifies where to begin the search.

Example:

<?php
echo strripos("Hello India..!!, Gud Morning","Morning");
?>

Output:

21

strrpos()

The strrpos() function finds the position of the last occurrence of a string inside another string.

Syntax:
strrpos(string,find,start)

In above syntax, "string" specifies the string to search, "find" specifies the string to find and "start" specifies where to begin the search.

Example:

<?php
echo strrpos("Gud Morning...!!, Gud morning India","morning");
?>

Output:

22

Previous Home Next