PHP array_key_exists and Float keys = No


I just had one of thouse bugs that makes you waste hours and once you find the solution you feel like the biggest idiot on the planet.

I was doing an array_key_exists and passing a floated number as key to check thinking that php would somehow cast it into an integer value. So while debugging i was looking an “integer” and getting FALSE everythime… i was going insane. array_key_exists with a flot returns false all the time.

Then, i after almost 2 hours, i started to think that mabe there was something wrong with the “type” of my key, and bingo.

DAAAAAMMMNNNnnn 2 hours to the trash, shit. Anyway, back to coding ;P

Advertisements