Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Str\search_ci() in Facebook's www repository.

Returns the first position of the "needle" string in the "haystack" string, or null if it isn't found (case-insensitive)

namespace HH\Lib\Str;

function search_ci(
  string $haystack,
  string $needle,
  int $offset = 0,
): ?int;

An optional offset determines where in the haystack the search begins. If the offset is negative, the search will begin that many characters from the end of the string. If the offset is out-of-bounds, a ViolationException will be thrown.

Previously known in PHP as stripos.


  • string $haystack
  • string $needle
  • int $offset = 0


  • ?int