最佳答案
我如何合并两个数组(一个与字符串=>值对和另一个与int =>值对),同时保持字符串/int键?它们都不会重叠(因为一个只有字符串,另一个只有整数)。
下面是我当前的代码(它不起作用,因为array_merge正在用整数键重新索引数组):
// get all id vars by combining the static and dynamic
$staticIdentifications = array(
Users::userID => "USERID",
Users::username => "USERNAME"
);
// get the dynamic vars, formatted: varID => varName
$companyVarIdentifications = CompanyVars::getIdentificationVarsFriendly($_SESSION['companyID']);
// merge the static and dynamic vars (*** BUT KEEP THE INT INDICES ***)
$idVars = array_merge($staticIdentifications, $companyVarIdentifications);