str_starts_with()
Performs a case-sensitive check indicating if the haystack begins with needle.
No Hooks.
Return
true|false
. True if $haystack starts with $needle, otherwise false.
Usage
str_starts_with( $haystack, $needle );
- $haystack(string) (required)
- The string to search in.
- $needle(string) (required)
- The substring to search for in the $haystack.
Changelog
Since 5.9.0 | Introduced. |
Code of str_starts_with() str starts with WP 6.0
function str_starts_with( $haystack, $needle ) { if ( '' === $needle ) { return true; } return 0 === strpos( $haystack, $needle ); }