Reputation: 309
I have a some simple JSON:
"feed" : [
{
"title" : "some title",
"link" : "http://somelink.com",
"image" : {
"url" : "http://somelink.com/image.png",
"offset" : "0.0"
}
}
]
In my PHP i'm adding a new feed item to my JSON. I can populate everything fine except my 'image' item.
I'm using:
array_push($json['feed'], 'image' => array('url' => 'http://gijfsdf.com/', 'offset' => '0.0'));
but that gives me a syntax error: Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) on line 18
Upvotes: 1
Views: 113
Reputation: 2705
you have to put image inside array like
array_push($json['feed'], array('image' => array('url' => 'http://gijfsdf.com/', 'offset' => '0.0')));
Upvotes: 2