php - Codeigniter Add new key and value to object(stdClass) inside foreach loop -


i trying add key , value array inside foreach loop. have following array.

    array (size=2)   0 =>      object(stdclass)[27]       public 'id' => string '1' (length=1)       public 'sectiontitle' => string 'personal information' (length=20)       public 'field_format' => string 'vertical' (length=8)       public 'status' => string '1' (length=1) 

and php code

       foreach ($query->result() $row) {             $data[] = $row;          }         var_dump($data);         return $data; 

i add key [fields] , value string it.

try

foreach ($query->result() $row) {                 $row->newkey = $newvalue;                 $data[] = $row;              }             var_dump($data);             return $data; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -