protected function normalizeData($data, $field, $separator = ',')
    {
        $normalized = [];

        foreach ($data as $key => $value) {
            if (strpos($key, '_') === 0 && strpos($key, $field) === 1) {
                $path = explode('_', str_replace('_' . $field, '', $key));
                $normalized[$path[1]] = $value;
            }
        }

        $compiled = [];

        foreach ($normalized as $key => $value) {
            if ($value === null) {
                continue;
            }
            foreach (explode($separator, $value) as $i => $val) {
                $compiled[$i][$key] = $val;
            }
        }
        $compiled = array_unique($compiled, SORT_REGULAR);

        return $compiled;
    }
protected function normalizeData($data, $field, $separator = ',')
    {
        $normalized = [];

        foreach ($data as $key => $value) {
            if (strpos($key, '_') === 0 && strpos($key, $field) === 1) {
                $path = explode('_', str_replace('_' . $field, '', $key));
                $normalized[$path[1]] = $value;
            }
        }

        $compiled = [];

        foreach ($normalized as $key => $value) {
            if ($value === null) {
                continue;
            }
            foreach (explode($separator, $value) as $i => $val) {
                $compiled[$i][$key] = $val;
            }
        }
        $compiled = array_unique($compiled, SORT_REGULAR);

        return $compiled;
    }
protected function normalizeData ( $ data , $ field , $ separator = ',' ) { $ normalized = [ ] ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , '_' ) === 0 && strpos ( $ key , $ field ) === 1 ) { $ path = explode ( '_' , str_replace ( '_' . $ field , '' , $ key ) ) ; $ normalized [ $ path [ 1 ] ] = $ value ; } } $ compiled = [ ] ; foreach ( $ normalized as $ key => $ value ) { if ( $ value === null ) { continue ; } foreach ( explode ( $ separator , $ value ) as $ i => $ val ) { $ compiled [ $ i ] [ $ key ] = $ val ; } } $ compiled = array_unique ( $ compiled , SORT_REGULAR ) ; return $ compiled ; }
This method takes the flat underscore separated key->value data that comes from the query result
and turns it into a properly structured array. The second part of the method also removes duplicate
values in the case where an aggregate query returns more than one copy of the row.

For example, `_from_id => "4,4,4"` gets normalized to `['fromid'=>4]`

@param Traversable $data
@param string      $field
@param string      $separator

@return array
This method takes the flat underscore separated key - > value data that comes from the query result and turns it into a properly structured array . The second part of the method also removes duplicate values in the case where an aggregate query returns more than one copy of the row .