Reputation: 197
How can I make this into a boolean?
I tried this :
array('FALSE' => 'No', 'TRUE' => 'Yes')
I want the TRUE/FALSE to be treated as a boolean and not a string. How to do this?
Upvotes: 0
Views: 76
Reputation: 164764
When you put values in quotes, they are treated as strings. Simply use the true
and false
boolean keywords, eg
array(
false => 'No',
true => 'Yes'
)
Be mindful that PHP will auto-cast true
to 1
and false
to 0
in this case because
The (array) key can either be an integer or a string
This won't stop you being able to use $array[true]
or $array[false]
though.
See http://php.net/manual/language.types.array.php
Upvotes: 1