I am trying to sort the mysql data by my calculated value. I know rsort(), sort(), however, I cannot sort them individual outside the foreach because it will not be consistent. I have three arrays need to be in consistent when I only want to sort them by the percentage. How can I do that? Appreciate.
<?php
//certain mysql connection code hide because it's not relative to this question.
foreach ($rows as row) {
$member_id=row['user_id'];
$count=row['count'];
$user_link[]=bp_core_get_user_domain( $member_id );
$user_displayname[]=bp_core_get_user_displayname( $member_id );
$combine_count[]=round(($count/$count_user_diff)*100);//calculate value
}//foreach
//how can I sort data here since I have three arrays together.
for ($i=0; $i<7; $i++){
echo "<a href='$user_link[$i]'><div>$user_avatar[$i]<ul>$combine_count[$i]</ul></div></a>";
}
?>