Archive for September 1st, 2009

Çok boyutlu bir dizide istediğim alana göre sıralama yapabilmek .
işte örnek bir kod:

PHP:
  1. foreach ($data as $row){
  2.     $smarty_data[$ii]['title'] = $row->title;
  3.     $smarty_data[$ii]['visit_count'] = $ziyaretler[$row->urun_id];
  4.     $ii++;
  5. }
  6.  
  7. function cmp($a, $b) {
  8.     if ($a['visit_count'] == $b['visit_count']) {
  9.         return 0;
  10.     }
  11.     return ($a['visit_count'] <$b['visit_count']) ? 1 : -1;
  12. }
  13.  
  14. usort($smarty_data, "cmp");