<?php
$json = <<<'EOL'
{
"syndicate-to": [
{
"uid": "https://myfavoritesocialnetwork.example/aaronpk",
"name": "aaronpk on myfavoritesocialnetwork",
"service": {
"name": "My Favorite Social Network",
"url": "https://myfavoritesocialnetwork.example/",
"photo": "https://myfavoritesocialnetwork.example/img/icon.png"
},
"user": {
"name": "aaronpk",
"url": "https://myfavoritesocialnetwork.example/aaronpk",
"photo": "https://myfavoritesocialnetwork.example/aaronpk/photo.jpg"
}
}
]
}
EOL;
$data = json_decode($json);
var_dump($data);
var_dump(json_last_error());
var_dump($data->{'syndicate-to'}[0]->uid);
- Output for 7.0.0 - 7.0.32, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
- object(stdClass)#4 (1) {
["syndicate-to"]=>
array(1) {
[0]=>
object(stdClass)#1 (4) {
["uid"]=>
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
["name"]=>
string(34) "aaronpk on myfavoritesocialnetwork"
["service"]=>
object(stdClass)#2 (3) {
["name"]=>
string(26) "My Favorite Social Network"
["url"]=>
string(40) "https://myfavoritesocialnetwork.example/"
["photo"]=>
string(52) "https://myfavoritesocialnetwork.example/img/icon.png"
}
["user"]=>
object(stdClass)#3 (3) {
["name"]=>
string(7) "aaronpk"
["url"]=>
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
["photo"]=>
string(57) "https://myfavoritesocialnetwork.example/aaronpk/photo.jpg"
}
}
}
}
int(0)
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
- object(stdClass)#1 (1) {
["syndicate-to"]=>
array(1) {
[0]=>
object(stdClass)#2 (4) {
["uid"]=>
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
["name"]=>
string(34) "aaronpk on myfavoritesocialnetwork"
["service"]=>
object(stdClass)#3 (3) {
["name"]=>
string(26) "My Favorite Social Network"
["url"]=>
string(40) "https://myfavoritesocialnetwork.example/"
["photo"]=>
string(52) "https://myfavoritesocialnetwork.example/img/icon.png"
}
["user"]=>
object(stdClass)#4 (3) {
["name"]=>
string(7) "aaronpk"
["url"]=>
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
["photo"]=>
string(57) "https://myfavoritesocialnetwork.example/aaronpk/photo.jpg"
}
}
}
}
int(0)
string(47) "https://myfavoritesocialnetwork.example/aaronpk"
preferences:
64.21 ms | 410 KiB | 5 Q