Documentation - astrstr()

Description

  • int astrstr ( string $haystack, array $needles [, $offset [, int $flags ] ] )
    Returns the first instance of either the first needle found in the haystack, or the first instance of a needle in the haystack.

Parameters

  • haystack

    The string to search in

  • needle

    An array of strings to search in the haystack for

  • offset

    The optional offset parameter allows you to specify which character in haystack to start searching.

  • flags

    Option settings for how the search is conducted:

    • ASTR_NEEDLE_ORDER returns the first instance of a needle
    • ASTR_STRING_ORDER returns the first instance of any needle
    • ASTR_BEFORE_NEEDLE returns the string before the first instance of the needle
    • ASTR_AFTER_OFFSET returns the string between the offset and the first instance of the needle

Return Values

  • Returns the position as an integer. If needle is not found, astrpos() will return Boolean false.

    Warning: This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Make sure to use the === operator for testing the return value of this function.