0

I wrote a function. There is certain data in the dates. There is an array in this data and there are parameters such as id, number.. in it. So these are now objects, not arrays. I need to access "opened" and "loaded". In the figure, there are the controls I provide with dump and dd's. I have a very convoluted structure.

dd and dump

public function delayed_onHold($datas)
    {
        dump($datas);
        $days = array();
        $ldate = date('Y-m-d H:i:s');
        foreach ($datas as $key => $value) {
            dump($value);
            foreach($value as $x => $val) {
                dump(($val));
              }
        }
        dd();
    }

I tried $val["loaded"] or $val["opened"] but it gave an error that I can't access it because it is an object. How can I access them?

Aleyn
  • 35
  • 5
  • Try to access it as an object: `$val->loaded` and `$val->opened`. – KIKO Software Nov 16 '22 at 14:18
  • Please do not use screenshots to express textual questions details on Stack Overflow. Please do not post array data as `dd()` or `dump()` output on Stack Overflow -- contributors have a much easier time using your sample data if you offer it as the output from `var_export()` (preferred) or `json_encode()`. Any other format and contributors will have to painstakingly reformat your data before they can begin to use it in their sandbox tests. @Aleyn If there is a large amount of data, then remove irrelevant parts to form a [mcve]. – mickmackusa Nov 16 '22 at 21:55
  • Despite the seemingly off-topic title, the dupe target provided will demonstrate how to access object properties better than other pages that have a better aligning title. – mickmackusa Nov 16 '22 at 22:05

1 Answers1

-1

You can access the properties with $val->loaded. See more at https://www.php.net/manual/en/class.stdclass.php