Кто-нибудь знает, как узнать количество вхождений «фото» и «статус»?Я попытался вывести его в виде строки и выполнить substr_count, но безуспешно.
Array ( [0] => [1] => photo )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => status )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => status )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => status )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => photo )
Array ( [0] => [1] => status )
Array ( [0] => [1] => status )
Array ( [0] => [1] => status )
Array ( [0] => [1] => link )
Array ( [0] => [1] => status )
Исходный код JSON из API Graph Facebook:
{
"data": [
{
"id": "123",
"from": {
"name": "Some Name",
"category": "Food/beverages",
"id": "123"
},
"picture": "a pic",
"link": "a link",
"name": "bla bla ",
"caption": "9 new photos",
"icon": "a icon",
"actions": [
{
"name": "Comment",
"link": "a link"
},
{
"name": "Like",
"link": "a link"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE"
},
"type": "photo",
"object_id": "232342",
"created_time": "2012-03-01T14:58:53+0000",
"updated_time": "2012-03-02T14:12:50+0000",
"likes": {
"data": [
{
"name": "a name",
"id": "1234423"
}
],
"count": 58
},
"comments": {
"data": [
{
"id": "234234",
"from": {
"name": "a name",
"id": "23423234"
},
"message": "message bla bla",
"created_time": "2012-03-02T13:42:48+0000",
"likes": 2
},
{
"id": "234234234",
"from": {
"name": " a name",
"category": "Food/beverages",
"id": "123"
},
"message": "asfd",
"created_time": "2012-03-02T14:12:50+0000"
}
],
"count": 15
},
"is_published": true
},
{
"id": "123123",
"from": {
"name": "name",
"category": "Food/beverages",
"id": "123"
},
"message": "sadfasfd",
"actions": [
{
"name": "Comment",
"link": "a link"
},
{
"name": "Like",
"link": "a link"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE"
},
"type": "status",
"created_time": "2012-03-01T09:49:40+0000",
"updated_time": "2012-03-01T17:00:53+0000",
"likes": {
"data": [
{
"name": "name",
"id": "1000"
}
],
"count": 17
},
"comments": {
"data": [
{
"id": "1404",
"from": {
"name": "name",
"id": "1000"
},
"message": "bla bla",
"created_time": "2012-03-01T11:41:53+0000",
"likes": 2
},
{
"id": "1404781",
"from": {
"name": "name",
"id": "142"
},
"message": "message adsafasd",
"created_time": "2012-03-01T17:00:53+0000"
}
],
"count": 9
},
"is_published": true
},
Я выполняю код json_decode с выводом JSON, а затем циклически повторяю
foreach($ page_posts_overview-> данные как $ page_posts_overview_output) {
$type = " ".$page_posts_overview_output->type;
$type = explode(" ", $type);
$type = array($type);
print_r ($type);// this is what the output posted above
}