group array php by key

31

  private function group_by($array, $key) {
      $return = array();
      
      foreach($array as $val) {
          $return[$val->$key][] = $val; 
	  //  ou para gettype($val) = array
	  //  $return[$val[$key]][] = $val; 
      }
      return $return;
  }

Comments

Submit
0 Comments