CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

Unleashing the Power of the Boolean

| Comments

Now witness the firepower of this fully ARMED and OPERATIONAL boolean conversion function!

1
2
3
4
5
6
7
<?php
Function _toBoolean($str) {
    return $str ? 1 : 0;
}

// Use case:
$obj->set(DB::_toBoolean($arr['myIndex']));

“This function is soooo versatile. It takes care of non-existing indexes in databases, strings, … and converts them all to a boolean. Never mind the meaning of boolean.” — Anonymous submitter

Comments