key arrays should be integers when they are not what's happening exactly?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

how PHP rounds the numbers in this case ?

$a = array(
0.5 => 1,
0.8 => 2,
1.2 => 3,
1.8 => 4,
);
print_r($a);
echo round(0.5);

we cannot have float keys so they will be rounded but I am wondering for
example rounding 0.5 will return 1 so from 0.1 to 0.4 all will be rounded
to 0
so it seems it is not doing the logic like the round function because the
$a output is :
Array ( [0] => 2 [1] => 4 )
what is the logic here?

Sincerely
Negin Nickparsa

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux