Is substring in string php?

[PHP 8]

str_containsDetermine if a string contains a given substring

Description

str_contains[string $haystack, string $needle]: bool

Parameters

haystack

The string to search in.

needle

The substring to search for in the haystack.

Return Values

Returns true if needle is in haystack, false otherwise.

Examples

Example #1 Using the empty string ''

The above example will output:

Checking the existence of the empty string will always return true

Example #2 Showing case-sensitivity

Chủ Đề