In PHP I have an array $test
. Running var_dump($test)
looks like this:
array(2) {
[0]=>
object(stdClass)#2 (6) {
["name"]=>
string(45) "Lorem"
["title"]=>
string(96) "Lorem ipsum"
}
[1]=>
object(stdClass)#3 (6) {
["name"]=>
string(41) "Ipsum"
["title"]=>
string(86) "Dolor sit amet"
}
}
Now I need to add another field (url
) to the $test
objects so it looks like:
array(2) {
[0]=>
object(stdClass)#2 (6) {
["name"]=>
string(45) "Lorem"
["title"]=>
string(96) "Lorem ipsum"
["url"]=>
string(86) "http://www.google.com"
}
[1]=>
object(stdClass)#3 (6) {
["name"]=>
string(41) "Ipsum"
["title"]=>
string(86) "Dolor sit amet"
["url"]=>
string(86) "http://www.stackoverflow.com"
}
}
I've tried foreach()
and $test->append('xxxxxxxx');
, but am getting errors. Shouldn't this be real easy to do? What am I doing wrong?