2 回答

TA貢獻(xiàn)1936條經(jīng)驗(yàn) 獲得超7個(gè)贊
您有多種選擇,可以在數(shù)組中定義鍵:
$interestsAdd = [1,2,3];
$dataToReset = array (
'email_address' => 'x',
'status' => 'subscribed',
'interests' => $interestsAdd
);
或者之后添加:
$interestsAdd = [1,2,3];
$dataToReset = array (
'email_address' => 'x',
'status' => 'subscribed',
);
$dataToReset['interests'] = $interestsAdd;
或者與您當(dāng)前的結(jié)構(gòu)合并它們:
$interestsAdd = ['interests' => [1,2,3]];
$dataToReset = array_merge($dataToReset, $interestsAdd);

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超6個(gè)贊
嘗試像這樣設(shè)置你的第一個(gè)數(shù)組:
$dataToReset = [
'email_address' => $subEmail,
'status' => 'subscribed',
'interests' => [],
];
構(gòu)建 $interestsAdd 數(shù)組后,將其添加到第一個(gè)數(shù)組:
$dataToReset['interests'] = $interestsAdd;
- 2 回答
- 0 關(guān)注
- 147 瀏覽
添加回答
舉報(bào)