Remix.run Logo
▲ wesammikhail a day ago

I had this happen to me yesterday in spite of knowing about it because I was rushing. I added phone numbers as array keys to deduplicate the whole set. Some ended up as ints and some as strings.

PHP arrays are the most versatile part of the language. They're what actually makes the language so good in so many ways.

But typed arrays are a freaking requirement at this point and I've been screaming about it for years now... alas no response.

▲hparadiz a day ago | parent [-]

It's a performance optimization in this case. '1' is a string and you can hash it like all the other strings with PHP's fork of djbx33a or you can immediately store it at memory index 1. PHP tends to have a lot of old code using numeric strings so the performance benefit of not hashing all of those is obvious.

▲wesammikhail 20 hours ago | parent [-]

I never dug into it but I suspected memory optimization to be the reason. Thanks for confirming.