Я объявляю свой массив открытым
class Doctor extends CI_Controller {
public $prescription_drug = array();
.....
}
Мне нужен массив вроде следующего
Array
(
[0] => Array
(
[drugdoze] => 8
[drugname] => 80
[drugsize] => 5
[drugtype] => 1
[duration] =>
[rx_duration] => 2
[rx_instruction] => 3
[rx_special_note] => "test 1"
)
[1] => Array
(
[drugdoze] => 4
[drugname] => 10
[drugsize] => 5
[drugtype] => 3
[duration] => 1
[rx_duration] => 2
[rx_instruction] => 3
[rx_special_note] => "test 2"
)
[2] => Array
(
[drugdoze] => 1
[drugname] => 13
[drugsize] => 5
[drugtype] => 3
[duration] => 1
[rx_duration] => 2
[rx_instruction] => 3
[rx_special_note] => "test 3"
)
)
How can I append following array with
[3] => Array
(
[drugdoze] => 1
[drugname] => 13
[drugsize] => 5
[drugtype] => 3
[duration] => 1
[rx_duration] => 2
[rx_instruction] => 3
[rx_special_note] => "test 3"
)
У меня есть общественная функция
public function prescription_selected_drug_session()
{
$prescription_data= array(
'drugdoze' => $this->input->post("drugdoze"),
'drugname'=> $this->input->post("drugname"),
'drugsize' => $this->input->post("drugsize"),
'drugtype' =>$this->input->post("drugtype"),
'duration'=> $this->input->post("duration"),
'rx_duration' => $this->input->post("rx_duration"),
'rx_instruction'=>$this->input->post("rx_instruction"),
'rx_special_note' => $this->input->post("rx_special_note")
);
array_push($this->prescription_drug,$prescription_data);
}
Я вызываю функцию с помощью ajax. Но значение $this-> prescription_drug перезаписывается каждый раз, не прилагается.
Может кто-нибудь мне помочь?
Php не имеет гражданства. Каждый запрос ajax создает новый экземпляр Doctor
.
Вам необходимо будет сохранить данные в сеансе или базе данных или заполнить клиентскую часть