Array_keys () B function? Http://docs.php.net/manual/zh/function.array-keys.php
"aa","2"=>"bb","3"=>"cc","4"=>"bb"); $y1=array_keys($x,bb,false); $y2=array_keys($x,bb,true); print_r($x); print_r($y1); print_r($y2);?>
What is the role of the 3rd function parameters?
Why did the program go wrong?
Reply to discussion (solution)
Please refer to the following link for more information: http://baike.baidu.com/view/4068562.htm.
Change it to $ y2 = array_keys ($ x, "bb", true );
Why did the program go wrong?
Because bb is not a constant, and you do not enclose it in quotation marks.
The third parameter specifies whether to check the data type
Strict
Determine whether to use strict comparison (=) during search ).
The error is caused by $ y1 = array_keys ($ x, bb, false). bb is not enclosed in quotation marks. php first considers it a constant, and your code does not have a constant, so an error is reported.
The third parameter is to return the key name with the specified value based on the type,
$ X = array ("1" => "111111", "2" => "bb", "3" => "cc ", "4" => "bb ");
$ Y1 = array_keys ($ x, 111111, true); // no data will be returned (in the original number Group, "111111" is a string type, and here it is a number type)
The error message is that the string must be enclosed in single or double quotation marks.
$ Y1 = array_keys ($ x, "bb", false );
$ Y2 = array_keys ($ x, "bb", true );