array
$tagHolder[$row['id']] = array(
"name" => $row['name'],
"primary" =>开发者_如何学编程; $row['primary'],
"child" => $row['child'],
"order" => $row['order']
);
usort function
function sortAsc($x, $y){
if ( $x['order'] == $y['order'] )
return 0;
else if ( $x['order'] < $y['order'] )
return -1;
else
return 1;
}
Will order by 'order' BUT will not keep the original $row['id']
keys, instead it reassigns the first prosition as 0 and so on. How can I make the sort function sort but keep the $row['key']
untouched?
Use uasort
instead of usort
to keep the key association.
精彩评论