如何将数组元素传递给另一个数组以存储在php中的数据库中

Hi i am facing one problem in passing the array elements to another array...

$order=$this->ro_model->get_ro_details($order_id);

By using above function i will get query results into array name called $order.

Now i had form when it submits i will get some data from that form that i am saving in another name called $order_details.

$order_data=array(

    'amount'=>$this->input->post('amount'
);  

Now i wanna save both the arrays data in one table in database. For that what i thought was i can pass first array data to second array data and i will save all the data in one array. Then later i will send that array to a function which will insert the data into database.

$this->ro_model->add_amount($order_data);

My problem how to pass that first array data to second array...........

  • Note: All these are i am doing in codeigniter framework.

Use array_merge() function. Here you go: http://php.net/manual/en/function.array-merge.php

you can do it in 2 ways

  1. array_push Push one or more elements onto the end of array http://in3.php.net/manual/en/function.array-push.php
  2. array_merge Merge one or more arrays http://in3.php.net/manual/en/function.array-merge.php