Here is an array with only strings:
$array = ["1", "hello", "1", "world", "hello"];
Notice that "1"
is a string.
If I use array_count_values
on this array, it seems it silently converts strings to ints.
var_dump(array_count_values($array));
Echos:
array(3) { [1]=> int(2) ["hello"]=> int(2) ["world"]=> int(1) }
1
is now an int. I feel it's a weird behavior. Is it normal? Did I missed something? Is there a way to avoid this behavior?