Introduction to the php array array_change_key_case () function and the array_chunk () function, arraychunk

Source: Internet
Author: User

Introduction to the php array array_change_key_case () function and the array_chunk () function, arraychunk

As follows:

<? Php/* array_change_key_case () returns an array with uppercase or lowercase keys. Array array_change_key_case (array input [, int case]) parameter description: array is an array of key values to be converted. There are two options: CASE_LOWER. the default option is to return the key CASE_UPPER of the array with lowercase letters, returns the array key with uppercase letters */$ input_array = array ('A' => 'java', 'B' => 'php ', 'c' => 'C ++ ', 'D' => 'C # '); print_r (array_change_key_case ($ input_array, CASE_LOWER); print_r (array_change_key_case ($ input_array, CASE_UPPER); // if two or more keys are the same when running the function, the final element will overwrite other elements, for example: $ input_array = array ('A' => 'barri ',' B '=> 'Madrid', 'c' => 'manchester ',' B '=> 'milance'); print_r (array_change_key_case ($ input_array, CASE_LOWER);?>

Running result:

<? Php/* array_chunk () Splits an array into a new array block. The parameter description of array array_chunk (array $ array, int $ size [, bool preserve_key]) is as follows: array is the size of the split array, which specifies the elements contained in each new array. The last array may contain several fewer elements: preserve_key: (optional) there are two options: true, retain the key name in the original array; false, default option. Each result array uses A new array index starting from 0 */$ input_array = array ('A' => 'java ', 'B' => 'php', 'c' => 'C ++ ', 'D' => 'C #'); print_r (array_chunk ($ input_array, 2, false); print_r (array_chunk ($ input_array, 3, true);?>

Running result:

The above is a brief introduction to the php array array_change_key_case () function and the array_chunk () function ~

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.