I'm trying to push a new array key and value into the exiting array. Therefore, I use array_push
to append the data.
Code
$account_no = $acc_no['bank']['account_no'];
$new_account_no = [
$model->id => Input::get('account_no'),//This result is "32" => "1234562"
];
array_push($account_no, $new_account_no);
Result
"bank": {
"account_no": {
"23": "1111111111",
"24": {
"32": "1234562"
}
}
}
So now the problem is, the array data I pushed added a key 24
which is incorrect and it suppose only push "32": "1234562"
Expected result
"bank": {
"account_no": {
"23": "1111111111",
"32": "1234562"
}
}
$account_no[$model->id] = Input::get('account_no');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.