I am trying to create an array with the following structure:
[10] => Array
(
[10] => test key
...
[100] => test key
)
[20] => Array
(
[10] => test key
...
[100] => test key
)
[30] => Array
(
[10] => test key
...
[100] => test key
)
...
This is the loop that I use in order to create such structure:
$array = array();
for ($x = 0.1; $x <= 1; $x+=0.1) {
$index = $x*100;
for ($z = 10; $z <= 100; $z+=10) {
$array[(int)$index][$z] = 'test key';
}
}
Unfortunately, the output that I receive looks like this once it is supposed to reach the 90 and 100 index:
[80] => Array
(
[10] => test key
...
[100] => test key
)
[89] => Array
(
[10] => test key
...
[100] => test key
)
[99] => Array
(
[10] => test key
...
[100] => test key
)
Why does it calculate the index to be 89 and 99? Shouldn't it be 90 and 100 respectively?
*edit I am using floats as that's the measurement of percentages that we use to make some calculations. I know I could go by 10 increments as well, but that would require me to eventually divide by 100 again in order to get the float