022-PHP array sort asort

<? PHP    
     // construct an array variable 
    $ Users = Array ( " Bob " => " Yobert " , " Steve " => " Btephen " , " Jon " => " Aonathon " ); 
    
    / * loop output 
        reset () function the internal pointer to the first element in the array, and output. 
        Related methods: 
        Current () - returns the value of the current element in the array, and the key () function returns the name of the key elements. 
        end () - internal pointer to the last element in the array, and outputs the 
        next () - internal pointer to the next element in the array, and outputs 
        prev () - internal pointer to the last element in the array, and export
        each () - returns the key and the key of the current element, and the pointer is moved forward inside * / 
    for "(RESET ($ Users); $ index = Key ($ Users); Next ($ Users)) { 
        Print ( " $ index: $ Users [$ index] <BR> \ n- " ); 
    } 
    // <HR> tag Creating a horizontal line in an HTML page. 
    Print ( " <HR> " ); 
    
    / *   asort () function to the associated array in ascending order according to the key value. 
        Tip: Use arsort () function for associative arrays in descending order according to the key value. 
        Tip: Use ksort () function for an associative array in ascending order by key. * / 
    Asort ($ Users); 
    
    // array after printing is sorted 
    for (RESET ($ Users); $ index = Key ($ Users); Next ($ Users)) { 
        Print ( $ index: $ Users [$ index] <BR> \ the n- " ); 
    } >?

 

Guess you like

Origin www.cnblogs.com/tianpan2019/p/10987956.html