// 設定須要修改的鍵值數組 $renameMap = [ 'id' => 'ServiceProjectID', // old => new 'Name' => 'ServiceProjectName', 'FatherName' => 'ServiceProjectFatherName' ]; // 修改目標所在數組 $Back['Data'] foreach ($Back['Data'] as $key => $obj){ // 目標數組 $Back['Data'][$key] = array_combine(array_map(function($el) use ($renameMap) { // 只修改特定鍵值 if (isset($renameMap[$el])){ return $renameMap[$el]; }else{ // 返回原有鍵值 return $el; } }, array_keys($Back['Data'][$key])), array_values($Back['Data'][$key])); }