I have a PHP array like this:
index.php:
$state = [
'isLoggedIn' => false,
'isB2BCustomer' => false
];
print($twig->render('index.html', ['state' => $state]));
index.html:
{% for key, stateItem in state %}
<tr>
<td>{{ key }}: {{ stateItem }}</td>
</tr>
{% endfor %}
This gives me the following output:
|---------------------|
| State |
|---------------------|
| isLoggedIn: |
|---------------------|
| isB2BCustomer: |
|---------------------|
I'm expecting:
|---------------------|
| State |
|---------------------|
| isLoggedIn: 0 |
|---------------------|
| isB2BCustomer: 0 |
|---------------------|
It shows the keys correctly, but I can't seem to figure out how to get the value.
0forfalse??? 3v4l.org/DlR10 You'll either need to store0or display an actual0when the value isfalse.falsevalues to be output as0. Any idea about how to access the values?false, maybe{% if stateItem %}1{% else %}0{% endif%}or somesuch.