PHP multidimensional array php array function sequence Ksort the element key names of the array are sorted in ascending order, keeping the index relationship

Source: Internet
Author: User
Ksort () Definition and usage
The Ksort () function is sorted in ascending order by key name, preserving the original key for the array value.
The Second optional parameter contains an additional sort flag.
Returns TRUE if successful, otherwise FALSE is returned.
Grammar
Ksort (array,sorttype) parameter description
Array required. Specifies the array to sort.
SortType is optional. Specifies how the values of the array are arranged. Possible values:
Sort_regular-Default. Processed in their original type (without changing the type).
Sort_numeric-Handle the value as a number
Sort_string-handles the value as a string
Sort_locale_string-handles the value as a string, based on local settings *.
*: This value is new for PHP 4.4.0 and 5.0.2. Prior to PHP 6, the system's locale was used, which can be changed using setlocale (). From PHP 6, you must use the I18n_loc_set_default () function.
Example

Copy the Code code as follows:


$my _array = Array ("e" = "Dog", "b" = "Cat", "c" = "Horse");
Ksort ($my _array);
Print_r ($my _array);
?>


Output:
Array ([b] = Cat [c] = Horse [E] = Sog)

The above describes the PHP multidimensional array php array function sequence Ksort the element key name of the array in ascending order, keep the index relationship, including the contents of the PHP multidimensional array, I hope to be interested in PHP tutorial friends helpful.

  • 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.