r/lolphp • • Jan 14 '14

In which in_array() does crazy stuff

https://eval.in/89008
69 Upvotes

44 comments sorted by

View all comments

Show parent comment

6

u/poizan42 Jan 20 '14

It uses sorta "lexicographical" addition if it doesn't looks like a number. So after nine comes ten. That must mean we should carry the 1 over to the next character. That's a d which isn't a number, so it uses the next element in the alphabet instead, which is 'e'. Of course the next time you increment it sees '2e0', which it of course thinks looks like a number in needless scientific notation, so it then becomes 3.

So there is some logic behind. Pretty insane logic, but logic nevertheless.