Home >Backend Development >PHP Tutorial >Detailed explanation of the functional features of PHP function arsort()_PHP Tutorial
Everyone is learningThe following Listing F code is an example of using the PHP function arsort():
<ol class="dp-xml"> <li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=alt><SPAN><SPAN></SPAN></SPAN><LI class=alt><SPAN><SPAN>$</SPAN><SPAN class=attribute><FONT color=#ff0000>data</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>array</FONT></SPAN><SPAN>("US" =</SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong></span><span> "United States", "IN" <br>=</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "India", "DE" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> "Germany", "ES" =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> <br>"Spain");arsort($data); print_r($data); </span> </li> <li class=""><span class="tag"></span></li> <li class=""> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li> </ol>
The following is its output, sorted alphabetically by value. Comparing the following results with the results generated after inversion using the krsort() function, you can easily understand the difference between the two.
Array ([US] => United States
[ES] => Spain
[IN] => India
[DE] => Germany
)
The example introduced above is the specific use of the PHP function arsort().