Several useful small functions (array de-weight, array, string sort)

Source: Internet
Author: User

1, array de-weight (array_unique):

<?php
$a =array ("a" and "cat", "B" and "Dog", "c" = "cat");
Print_r (Array_unique ($a));
?>

Output:

Array ([A] = Cat [b] = Dog)

2, array, string sort (sort):

Sort (array,sortingtype);
Array: Required. Specifies the array to be sorted.
Sortingtype:
Optional. Specifies how to compare elements/items of an array. Possible values:
    • 0 = sort_regular-default. Arrange each item in the usual order (standard ASCII, no change type)
    • 1 = sort_numeric-Each item is treated as a number.
    • 2 = sort_string-Each item is treated as a string.
    • 3 = sort_locale_string-handles each item as a string, based on the current locale (can be changed by setlocale ()).
    • 4 = sort_natural-handles each item as a string, using a natural sort similar to Natsort ().
    • 5 = sort_flag_case-You can sort strings by combining (bitwise OR) sort_string or sort_natural, not case-sensitive.

Several useful small functions (array de-weight, array, string sort)

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.