I have an object $userStatus which is fetching the values in the following format via an API call.

I am unable to allocate the values via loop.

```
foreach($usersStatus as $user => $element) {    
        print "[".$user."] => ". $element ."<br />";
    }

```

The following script in php allows me to print the first set of values until the key ["total\_time"] => String96) "6m 34s" but then I get a following warning

**Warning**: Array to string conversion in C:\XAMPP\htdocs\Check-status.php on line 119
[units] => Array

Is there a way, I can traverse the whole object including the two arrays [0][1] using a loop and assign any value to any variable.

I know vardump will print the whole thing, but I want to traverse the whole object via loop or nested loops.

```
["role"]=>string(7) "learner"
["enrolled_on"]=>string(20) "05/01/2021, 17:44:53"
["enrolled_on_timestamp"]=>string(10) "1609868693"
["completion_status"]=>string(9) "Completed"
["completion_percentage"]=>string(3) "100"
["completed_on"]=>string(20) "06/01/2021, 16:58:23"
["completed_on_timestamp"]=>string(10) "1609952303"
["expired_on"]=>string(0) ""
["expired_on_timestamp"]=>NULL 
["total_time"]=>string(6) "6m 34s"

["units"]=>array(2) {
    [0]=>array(8) {
        ["id"]=>string(4) "2047"
        ["name"]=>string(26) "MyCourse1 2019"
        ["type"]=>string(19) "SCORM | xAPI | cmi5"
        ["completion_status"]=>string(9) "Completed"
        ["completed_on"]=>string(20) "06/01/2021, 16:58:23"
        ["completed_on_timestamp"]=>string(10) "1609952303"
        ["score"]=>NULL 
        ["total_time"]=>string(6) "3m 56s"
    }

    [1]=>array(8) {
        ["id"]=>string(4) "2059"
        ["name"]=>string(34) "Assessment - MyCourse1"
        ["type"]=>string(4) "Test"
        ["completion_status"]=>string(9) "Completed"
        ["completed_on"]=>string(20) "06/01/2021, 15:06:56"
        ["completed_on_timestamp"]=>string(10) "1609945616"
        ["score"]=>string(5) "91.67"
        ["total_time"]=>string(6) "2m 38s"
    }
}

```

Thank you for your help!