简体   繁体   中英

Sorting php array by value

I have this array in my php code:

    Array
(
    [190] => 2
    [193] => 1
    [196] => 1
    [199] => 1
    [206] => 2
    [208] => 2

)

I need to sort it in descending order. I am doing this:

$sortDid = arsort($dids);

But this is not working. What's wrong here?

arsort modify array by reference. arsort returns bool value. Remove assign to variable:

arsort($dids);
var_dump($dids);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM