Php uses the sort () function to sort arrays. sort array _ PHP Tutorial

Source: Internet
Author: User
Php uses the sort () function to sort arrays. Php uses the sort () function to sort arrays. This document describes how php uses the sort () function to sort arrays. Share it with you for your reference. The specific analysis is as follows: php uses the sort () function to sort arrays.

This example describes how php sorts arrays using the sort () function. Share it with you for your reference. The specific analysis is as follows:

The sort () function is used to sort arrays. this function assigns a new key name to the elements in the array. The original key name is deleted.
If the call succeeds, TRUE is returned. otherwise, FALSE is returned.

$ Alpha = array ("x", "a", "f", "c"); sort ($ alpha); foreach ($ alpha as $ var) {print "$ var
";}

Example 2

<? Php $ my_array = array ("a" => "Dog", "B" => "Cat", "c" => "Horse"); sort ($ my_array ); print_r ($ my_array);?>

Returned results

Array ([0] => Cat [1] => Dog [2] => Horse)

I hope this article will help you with php programming.

The sort () function sorts arrays. This article describes how php uses the sort () function to sort arrays. Share it with you for your reference. The specific analysis is as follows :...

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.