0

How can I do an array of boolean of 100 values initialized by false

I'm trying to do an array of 100 boolean values (false values) I used the function array_fill to do so but when in the third argument I put false the output is empty, when I replace it with true I have the values initialized by 1. https://code.sololearn.com/whLzVcbsi7IV/?ref=app

13th Sep 2020, 3:38 PM
Adrien Linares
Adrien Linares - avatar
2 Réponses
+ 1
Code works fine, it's just that PHP's way for printing boolean values. Being converted to string - a boolean true is represented by '1', while boolean false is represented by an empty string. You can still see the values by casting the boolean into int. echo (int)$k . '\n';
13th Sep 2020, 3:48 PM
Ipang
+ 1
Oh, Thanks!
13th Sep 2020, 3:50 PM
Adrien Linares
Adrien Linares - avatar