wc_string_to_bool()
Converts a string (e.g. 'yes' or 'no') to a bool.
No Hooks.
Return
true|false
.
Usage
wc_string_to_bool( $string );
- $string(string|true|false) (required)
- String to convert. If a bool is passed it will be returned as-is.
Changelog
Since 3.0.0 | Introduced. |
wc_string_to_bool() wc string to bool code WC 9.6.1
function wc_string_to_bool( $string ) { $string = $string ?? ''; return is_bool( $string ) ? $string : ( 'yes' === strtolower( $string ) || 1 === $string || 'true' === strtolower( $string ) || '1' === $string ); }