Array_search () function, 3rd parameter, what is the function?
http://docs.php.net/manual/zh/function.array-search.php
Mixed Array_search (mixed $needle, array $haystack [, bool $strict = false])
Strict
If the optional third parameter, strict, is TRUE, Array_search () examines the exact same element in haystack. This means that the type of needle in haystack is also checked, and the object needs to be the same instance.
Problem:
This function, the 3rd parameter: $strict = False, what is the function?
Give an example.
Share to:
------Solution--------------------
$ar = Array (1, 2, 3);
Var_dump (Array_search (' 2 ', $ar, true)); BOOL (FALSE)
Var_dump (Array_search (2, $ar)); Int (1)
------Solution--------------------
$a = Array ("A" = "5", "B" =>5);
Echo Array_search (5, $a); the string "5" matches successfully without judging the type of the value
Echo '
';
Echo Array_search (5, $a, true); the type of the value to be judged so the string "5" matches the unsuccessful number 5 match succeeded