Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

stristr

Description

The stristr of String for PHP case-insensitive strstr().

Syntax

stristr(
    string $haystack,
    string $needle,
    bool $before_needle = false
): string|false

Parameters

haystack

The string to search in.

needle

The string to search for.

before_needle

If true, stristr() returns the part of the haystack before the first occurrence of the needle (excluding needle).

Return

Returns the matched substring. If needle is not found, returns false.

Examples

1 · haystack needle

<?

$haystack = 'CASEcase';
$needle = 's';

$return = stristr($haystack, $needle);

echo $return;

?>
SEcase

2 · before_needle

<?

$haystack = 'CASEcase';
$needle = 's';
$before_needle = true;

$return = stristr($haystack, $needle, $before_needle);

echo $return;

?>
CA
HomeMenu