user275074
user275074

Reputation:

Obtaining JSON object value from array

Is there a way to get the values of a JSON object member variable from a array without looping the objects? Similar to how call_user_func_array would work but for member variables?

E.g.

     array   0 => 
     object(stdClass)[402]
       public 'id' => int 196
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   1 => 
     object(stdClass)[403]
       public 'id' => int 197
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   2 => 
     object(stdClass)[404]
       public 'id' => int 3269
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   3 => 
     object(stdClass)[405]
       public 'id' => int 3334
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   4 => 
     object(stdClass)[406]
       public 'id' => int 5831
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   5 => 
     object(stdClass)[379]
       public 'id' => int 6358
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0   6 => 
     object(stdClass)[400]
       public 'id' => int 6592
       public 'creditLimit' => string '0' (length=1)
       public 'state' => int 0

In one single call I'm trying to obtain the summation of creditLimit.

Upvotes: 0

Views: 62

Answers (1)

Ven
Ven

Reputation: 19040

Pass "true" to json_decode to get a regular array.

Upvotes: 1

Related Questions