public function indexBy(array $data, $key)
    {
        $newData = [];
        foreach ($data as $row) {
            $newData[$row[$key]] = $row;
        }

        return $newData;
    }
public function indexBy(array $data, $key)
    {
        $newData = [];
        foreach ($data as $row) {
            $newData[$row[$key]] = $row;
        }

        return $newData;
    }
public function indexBy ( array $ data , $ key ) { $ newData = [ ] ; foreach ( $ data as $ row ) { $ newData [ $ row [ $ key ] ] = $ row ; } return $ newData ; }
Specifies a field to be the key of the array

@param array $data
@param string $key
@return array
Specifies a field to be the key of the array