wpseek.com
A WordPress-centric search engine for devs and theme authors



str_contains › WordPress Function

Since5.9.0
Deprecatedn/a
str_contains ( $haystack, $needle )
Parameters: (2)
  • (string) $haystack The string to search in.
    Required: Yes
  • (string) $needle The substring to search for in the `$haystack`.
    Required: Yes
Returns:
  • (bool) True if `$needle` is in `$haystack`, otherwise false.
Defined at:
Codex:

Polyfill for `str_contains()` function added in PHP 8.0.

Performs a case-sensitive check indicating if needle is contained in haystack.


Source

function str_contains( $haystack, $needle ) {
		if ( '' === $needle ) {
			return true;
		}

		return false !== strpos( $haystack, $needle );
	}
}