bool_from_yn() WordPress Function
The bool_from_yn() function is used to convert a string value of "y" or "n" to a boolean value of true or false. This can be useful when working with data that is stored as a string, but you need to use it as a boolean value.
bool_from_yn( string $yn ) #
Whether input is yes or no.
Description
Must be ‘y’ to be true.
Parameters
- $yn
(string)(Required)Character string containing either 'y' (yes) or 'n' (no).
Return
(bool) True if 'y', false on anything else.
Source
File: wp-includes/functions.php
function bool_from_yn( $yn ) { return ( 'y' === strtolower( $yn ) ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |