Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i add key, value in PHP Object? (Codeigniter) [closed]

Example,

$params = array($demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum,$demandnum );
$stmt = $this->db_gcm->query($query, $params);
$test = $stmt->row();

print_r($test);

Result,

stdClass Object( [server_price] => 32398.63 [server_unit] => 2 [network_price] => 0.00 
[network_unit] => 3 [storage_price] => 4948.02 [storage_unit] => 2 
[loadbalancer_price] => 2200.00 [loadbalancer_unit] => 1 
[additionalservice_price] => 105375.60 [additionalservice_unit] => 4 [support_price] => [support_unit] => 0)

I want to add key value in here.

Is there any good idea?

like image 970
Canna Avatar asked Aug 27 '13 05:08

Canna


1 Answers

I want to add key value in here.

In where? $test? How about

$test->key = 'value';
like image 107
Phil Avatar answered Dec 16 '22 10:12

Phil