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.


Top ↑

Parameters

$yn

(string)(Required)Character string containing either 'y' (yes) or 'n' (no).


Top ↑

Return

(bool) True if 'y', false on anything else.


Top ↑

Source

File: wp-includes/functions.php

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

Top ↑

Changelog

Changelog
VersionDescription
1.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More