Common array functions in php (5) (obtain the set of key names in the array) and array key names

Source: Internet
Author: User

Common array functions in php (5) (obtain the set of key names in the array) and array key names
Array_keys ($ arr, $ search_value, $ strict );

-- Obtains the set of key names in the array.

// The array to be retrieved in parameter 1; the default value of the key to be retrieved in parameter 2 is NULL; and the default value of parameter 3 is false if it is strictly compared (=. Parameter 3 is added in php5.0.

$ Arr1 = array ('A' => 'apple', 'B' => 'bana', 'F' => false, 'b1 '=> false, 'b2' => false, 'b3' => 'false', 'b4 '=> true, 'num1' => 1, 'num2' => '1 '); // var_dump (array_keys ($ arr1, 'Banana '); var_dump (array_keys ($ arr1, 1, false ));

Output: array (3) {[0] => string (2) "b4" [1] => string (4) "num1" [2] => string (4) "num2 "}

There is no strict comparison. The true value of the index 'b4 'is also treated as 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.