Home > Article > Backend Development > Tips on using the PHParray_multisort function
This article mainly introduces the usage skills of PHParray_multisort function. Interested friends can refer to it. I hope it will be helpful to everyone.
The implementation code is as follows:
<?php $array[] = array('id'=>1,'price'=>50); $array[] = array('id'=>2,'price'=>70); $array[] = array('id'=>3,'price'=>30); $array[] = array('id'=>4,'price'=>20); foreach ($array as $key=>$value){ $id[$key] = $value['id']; $price[$key] = $value['price']; } array_multisort($price,SORT_NUMERIC,SORT_DESC,$id,SORT_STRING,SORT_ASC,$array); echo '<pre class="brush:php;toolbar:false">'; print_r($array); echo ''; ?>
Running results:
Array ( [0] => Array ( [id] => 2 [price] => 70 ) [1] => Array ( [id] => 1 [price] => 50 ) [2] => Array ( [id] => 3 [price] => 30 ) [3] => Array ( [id] => 4 [price] => 20 ) )
Summary: The above is the entire content of this article, I hope it can help everyone learn Helps.
Related recommendations:
Data transmission CURL instance analysis in PHP
##Example of website directory scanning indexing tool based on PHP
How to implement fuzzy query in PHP
The above is the detailed content of Tips on using the PHParray_multisort function. For more information, please follow other related articles on the PHP Chinese website!