PHP strstr() Function Example

PHP Script:

<?php
echo strstr(“PHP str str function example on PHPTUTORS”,”PHPTUTORS”);
?>

Output:

PHPTUTORS

Description:

strstr() function searches for the first occurrence of a string inside another string.
This function returns the string from the matching point like PHPTUTORS in above example script or if the string is not found false will be return.
This function is case-sensitive.

strstr function parameters:

1- String: string to search.
2- Search string: Specify the string to search for. We can also provide a number so, characters ASCII value matching is performed with this number.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s