Created
September 2, 2020 09:30
-
-
Save riza/cb881b667f82ca83fb18b90cb20c61f5 to your computer and use it in GitHub Desktop.
The REAL Boolval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* | |
* | |
*/ | |
function _boolval($val) { | |
return $val === "true" ? true : ($val === true ? true : ($val === "false" ? false : ($val === false ? false : (is_numeric($val) ? (intval($val) >= 1 ? true : false) : (!empty($val) ? true : false))))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment