bool_from_yn

Whether input is yes or no.

Description

bool_from_yn( (string) $yn ); 

Must be y to be true.

Parameters (1)

0. $yn (string)
Character string containing either y (yes) or n (no).

Usage

  1. if ( !function_exists( 'bool_from_yn' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Character string containing either 'y' (yes) or 'n' (no). 
  5. $yn = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bool_from_yn($yn); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function bool_from_yn( $yn ) { 
  2. return ( strtolower( $yn ) == 'y' );