public static function str_to_bool($string, $default = false)
{
$yes_words = 'affirmative|all right|aye|indubitably|most assuredly|ok|of course|okay|sure thing|y|yes+|yea|yep|sure|yeah|true|t|on|1|oui|vrai';
$no_words = 'no*|no way|nope|nah|na|never|absolutely not|by no means|negative|never ever|false|f|off|0|non|faux';
if (preg_match('/^(' . $yes_words . ')$/i', $string)) {
return true;
} else {
if (preg_match('/^(' . $no_words . ')$/i', $string)) {
return false;
}
}
return $default;
}