Parameter Order in PHP's Built-In Functions

May 19, 2011

There does seem to be a "method to the madness" in the parameter order of PHP's built-in functions. 

For array functions the order is (needle, haystack).

For string functions, the order is (haystack, needle).

Array Function Example (needle, haystack):

array_key_exists( mixed $key , array $search )

String Function Example (haystack, needle):

stripos ( string $haystack , string $needle [, int $offset = 0 ] )

Short url :