PHP needles and haystacks

I was skim reading  ”PHP – The Good Parts” yesterday to see if there was anything new in it. The following lines caught my eye – never knew this!

The position of needle/haystack parameters in string functions is the reverse of the parameters in array functions.

strstr($haystack, $needle)
array_search($needle, $haystack)

I just assumed the developers were completely insane and chose parameter orders at random.

Posted in PHP at July 21st, 2010. No Comments.