You can just do `preg_replace('/\[\]$/', '', $data_type)`.