我有大量结果作为来自用于 csv 导出的 cakePHP 模型的数组。我一直在使用循环进行格式化,如下所示。随着记录数量的增长,这变得太慢并给出超时错误。有没有更好的方法使用 cakephp 哈希或 php 数组函数来做到这一点?
foreach($people as $person){
array_push($results, array(
'SchoolName'=> $person['School']['name'],
'SchoolRef' => $person['School']['ref'],
'firstName' => $person['Person']['firstname'],
'LastName' => $person['Person']['lastname'],
'Year1' => $person['Person']['year_1'],
'StudentID' => $person['Person']['studentid'],
'Email' => $person['Person']['email']
));
}