php - insert element on array on private function -


how can insert element final position of array array on private function??

private function getdata() {      return array(             1 => array(                     'open_cookie_id' => 1,                     'text' => 'i may throw on ya',                     'who'  => 'leonard mccoy',             ),             2 => array(                     'open_cookie_id' => 2,                     'text' => 'i think these things pretty safe.',                     'who' => 'james t. kirk'             ),             3 => array(                     'open_cookie_id' => 3,                     'text' => 'well, hate break you, starfleet operates in space.',                     'who' => 'james t. kirk'             ),             4 => array(                     'open_cookie_id' => 4,                     'text' => 'yeah. well, got else go. ex-wife took whole damn planet in divorce. got left bones.',                     'who' => 'leonard mccoy'             ),             5 => array(                     'open_cookie_id' => 5,                     'text' => 'if eliminate impossible, whatever remains, improbable, must truth.',                     'who' => 'spock'             )     );  } 

how insert element 6 , 7, 8 etc final array on these function private other function function:

  /**      * create resource      *      * @param  mixed $data      * @return apiproblem|mixed      */     public function create($data)     {         //return new apiproblem(405, 'the post method has not been defined');         //return $this->create($data) ;         $adapter = new arrayadapter($this->getdata());         $adapter2 = array         (             $data->open_cookie_id => array(                                     'open_cookie_id'=>$data->open_cookie_id ,                                     'text' =>$data->text,                                      'who' => $data->who                                         )         );          $adapter2_converted = new arrayadapter($adapter2);         //operation merge 2 arayadapter ($adapter+$adapter2_convert)        // $collection = new opencookiecollection($final_adapter);         //return $collection;     } 

i'm using php zend framework , apigility.

the function private not array can safely work returned array. notice $adapter arrayadapter data type, not simple array can't simple push.

my suggestion add method arrayadapter uses php array_push() add array arrayadapter data structure , use this: $adapter->pusharray($adapter2);


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -