PHP: usort magic
Dec.21, 2011 in
Think PHP
usort is very useful when one wants to combine or manipulate the results especially received from the db.
say for example we have an array named $displayProduct and we want to sort by the associative array call ‘order’
usort($displayProduct, function($a, $b) {return ($a['order'] < $b['order']) ? -1 : 1; });

Leave a Reply