library/database/class.dataset.php
public static function Index($Data, $Columns, $Options = array()) {
      $Columns = (array)$Columns;
      $Result = array();
      $Options = array_change_key_case($Options);

      if (is_string($Options))
         $Options = array('sep' => $Options);

      $Sep = GetValue('sep', $Options, '|');
      $Unique = GetValue('unique', $Options, TRUE);

      foreach ($Data as $Row) {
         $IndexValues = array();
         foreach ($Columns as $Column) {
            $IndexValues[] = GetValue($Column, $Row);
         }
         $Index = implode($Sep, $IndexValues);

         if ($Unique)
            $Result[$Index] = $Row;
         else
            $Result[$Index][] = $Row;
      }
      return $Result;
   }
public static function Index($Data, $Columns, $Options = array()) {
      $Columns = (array)$Columns;
      $Result = array();
      $Options = array_change_key_case($Options);

      if (is_string($Options))
         $Options = array('sep' => $Options);

      $Sep = GetValue('sep', $Options, '|');
      $Unique = GetValue('unique', $Options, TRUE);

      foreach ($Data as $Row) {
         $IndexValues = array();
         foreach ($Columns as $Column) {
            $IndexValues[] = GetValue($Column, $Row);
         }
         $Index = implode($Sep, $IndexValues);

         if ($Unique)
            $Result[$Index] = $Row;
         else
            $Result[$Index][] = $Row;
      }
      return $Result;
   }
public static function Index ( $ Data , $ Columns , $ Options = array ( ) ) { $ Columns = ( array ) $ Columns ; $ Result = array ( ) ; $ Options = array_change_key_case ( $ Options ) ; if ( is_string ( $ Options ) ) $ Options = array ( 'sep' => $ Options ) ; $ Sep = GetValue ( 'sep' , $ Options , '|' ) ; $ Unique = GetValue ( 'unique' , $ Options , TRUE ) ; foreach ( $ Data as $ Row ) { $ IndexValues = array ( ) ; foreach ( $ Columns as $ Column ) { $ IndexValues [ ] = GetValue ( $ Column , $ Row ) ; } $ Index = implode ( $ Sep , $ IndexValues ) ; if ( $ Unique ) $ Result [ $ Index ] = $ Row ; else $ Result [ $ Index ] [ ] = $ Row ; } return $ Result ; }
Index a result array.
@param array $Data The array to index. It is formatted similar to the array returned by Gdn_DataSet::Result().
@param string|array $Columns The name of the column to index on or an array of columns to index on.
@param array $Options An array of options for the method.
- <b>Sep</b>: The string to seperate index columns by. Default '|'.
- <b>Unique</b>: Whether or not the results are unique.
- <b>true</b> (default): The index is unique.
- <b>false</b>: The index is not unique and each indexed row will be an array or arrays.
@return type
Index a result array .