I need to create an array using a object using different format/structure
I have:
$t = object()
$t > user = object()
$t > user > 0 (object) name = 'wilson';
$t > user > 0 (object) first = 'carl';
I need to get:
$t = array(
name = wilson
first name = phil
Here's what I tried and where I'm stuck
foreach($t as $a) {
foreach($a as $l) {
$arr[$l->0->name] = $l->0->first; // line 10
}
}
print_r($arr);
Now I get an error:
PHP Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' in homework1-a-1.php on line 10
What can I do to fix it?
print_r($t);and paste the output?