Automattic\WooCommerce\Utilities
StringUtil::contains()
Checks if one string is contained into another at any position.
Method of the class: StringUtil{}
No Hooks.
Return
true|false
. True if $contained is contained inside $string, false otherwise.
Usage
$result = StringUtil::contains( $string, $contained, $case_sensitive ): bool;
- $string(string) (required)
- The string we want to check.
- $contained(string) (required)
- The string we're looking for inside $string.
- $case_sensitive(true|false)
- Indicates whether the comparison should be case-sensitive.
Default: true
StringUtil::contains() StringUtil::contains code WC 9.4.2
public static function contains( string $string, string $contained, bool $case_sensitive = true ): bool { if ( $case_sensitive ) { return false !== strpos( $string, $contained ); } else { return false !== stripos( $string, $contained ); } }