bool_from_yn()WP 1.0.0

Whether input is yes or no.

Must be 'y' to be true.

No Hooks.

Return

true|false. True if 'y', false on anything else.

Usage

bool_from_yn( $yn );
$yn(string) (required)
Character string containing either 'y' (yes) or 'n' (no).

Examples

0

#1 An example of how bool_from_yn() works:

bool_from_yn( 'y' );   //> true
bool_from_yn( 'Y' );   //> true
bool_from_yn( 'yes' ); //> false
bool_from_yn( 'n' );   //> false
bool_from_yn( 'foo' ); //> false

Changelog

Since 1.0.0 Introduced.

bool_from_yn() code WP 6.5.3

function bool_from_yn( $yn ) {
	return ( 'y' === strtolower( $yn ) );
}