我使用CakePHP和檢索用戶信息的多維數組,進行計算,然後我想的是計算加入到每個用戶推值與PHP
陣列查找用戶後,這是數組
print_r($user_info);
Array
(
[0] => Array
(
[User] => Array
(
[id] => 1
[email] => [email protected]
[website] => www.admin.com
)
)
)
現在,我想在一個循環
array_push($user_info[$i]['User'],array('num_payments' => $customer_payments[$i]['num_payments']));
這裏補充一個「num_payments」鍵這個特定用戶的該結構的結果數組
Array
(
[0] => Array
(
[User] => Array
(
[id] => 1
[email] => [email protected]
[website] => www.admin.com
[0] => Array
(
[num_payments] => 1
)
)
)
)
我怎樣才能把它變成這個結構?
Array
(
[0] => Array
(
[User] => Array
(
[id] => 1
[email] => [email protected]
[website] => www.admin.com
[num_payments] => 1
)
)
)
所以才遍歷值? – user1443519
是 - 對於每個用戶 - 只需將num_payments'鍵添加到數組 –
哇,這很明顯。有時間離開鍵盤。謝謝! – user1443519