phparraysstdclass

how can I access the value of a stdclass in php


I want to access the int20 and int30 in the picture below. how can i do it?

here is my var_dump result:

array (size=2)
  0 => 
    array (size=1)
      0 => 
        object(stdClass)[238]
          public 'time' => int 20
  1 => 
    array (size=1)
      0 => 
        object(stdClass)[242]
          public 'time' => int 30

and here is my query:

$sum_time = array();
foreach ($a as $f) {
    $sum_time[] = DB::select("select time from quiz where '$f'=id");
}        
var_dump($sum_time);

Solution

  • Add this to your code to get an array of all the "time" values

    $times = array();
    foreach ($sum_time as $value) {
        $times[] = $value[0]->time;
    }