Sadan Lime
Sadan Lime

Reputation: 41

arsort() is returning true instead of the sorted array

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 -- $sortDid is always true.

Upvotes: 0

Views: 47

Answers (1)

Pyton
Pyton

Reputation: 1319

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

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

Upvotes: 5

Related Questions