stristr

Case-insensitive `strstr`

&reftitle.description; ``string``false```stristr` `string` `haystack` `string` `needle` `bool` `before_needle`&false;

Returns all of `haystack` starting from and including the first occurrence of `needle` to the end.

&reftitle.parameters;

`haystack`

- The string to search in

`needle`

- The string to search for.

  &strings.parameter.needle.non-string;

`before_needle`

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

`needle` and `haystack` are examined in a case-insensitive manner.

&reftitle.returnvalues;

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

&reftitle.changelog;

&Version; | &Description;
&strings.changelog.ascii-case-folding; &strings.changelog.needle-empty;
8.0.0 | Passing an &integer; as `needle` is no longer supported.
7.3.0 | Passing an &integer; as `needle` has been deprecated.

&reftitle.examples;

### `stristr` example

    <?php
      $email = 'USER@EXAMPLE.com';
      echo stristr($email, 'e'); // outputs ER@EXAMPLE.com
      echo stristr($email, 'e', true); // outputs US
    ?>

### Testing if a string is found or not

    <?php
      $string = 'Hello World!';
      if(stristr($string, 'earth') === FALSE) {
        echo '"earth" not found in string';
      }
    // outputs: "earth" not found in string
    ?>

### Using a non "string" needle

    <?php
      $string = 'APPLE';
      echo stristr($string, 97); // 97 = lowercase a
    // outputs: APPLE
    ?>

&reftitle.notes; ¬e.bin-safe;
&reftitle.seealso;

- `strstr`
- `strrchr`
- `stripos`
- `strpbrk`
- `preg_match`