why use $records[$formated] here?
$records[] = would to the same thing and you could remove the array_values() call in line 343