I have a Boolean variable which I want to convert to a string:
$res = true;
I need the converted value to be of the format: \"true\"
boolval()
works for complicated tables where declaring variables and adding loops and filters do not work. Example:
$result[$row['name'] . "" . (boolval($row['special_case']) ? 'True' : 'False') . " " . $row['more_fields'] = $tmp
where $tmp
is a key used in order to transpose other data. Here, I wanted the table to display "Yes" for 1 and nothing for 0, so used (boolval($row['special_case']) ? 'Yes' : '')
.
- 热议问题