Print Json array data

Hello everyone, I am a new user;)

I am looking for a php script to display all ID values with a php loop.

Can you help me ?

{
“data”: [
{
“id”: “706787726426295”
},
{
“id”: “2361755303918946”
},
{
“id”: “511889772684220”
},
{
“id”: “1755827587895677”
},
{
“id”: “407805586613197”
},
{
“id”: “297422357878074”
},
{
“id”: “10158408575433222”
},
{
“id”: “610409162776795”
},
{
“id”: “183037319289921”
},
{
“id”: “312598412997471”
},
{
“id”: “599282840481732”
},
{
“id”: “2321128021459283”
},
{
“id”: “648728432230930”
},
{
“id”: “662847677483475”
},
{
“id”: “10158215282168222”
},
{
“id”: “2157714654316966”
},
{
“id”: “2274475086141931”
},
{
“id”: “10158206785208222”
},
{
“id”: “1052043288335866”
},
{
“id”: “262209674670047”
},
{
“id”: “379821942762557”
},
{
“id”: “260050098007201”
},
{
“id”: “328538344400941”
},
{
“id”: “572444296532084”
},
{
“id”: “2363734047246192”
}
],
“paging”: {
“cursors”: {
“before”: “NzA2Nzg3NzI2NDI2Mjk1”,
“after”: “MjM2MzczNDA0NzI0NjE5MgZDZD”
},
“next”: “https://graph.facebook.com/v4.0/205698738221/videos?access_token=#####
}
}

Use json_decode() with the second parameter true, then catch “data” node and use array_column() to receive all values - no loop needed.

Is Correct ?

$data = file_get_contents(“XXXXXXXXX”);
$array = json_decode($data, true);
echo array_column();

Does it work?

I bet “no”, at least you get a few syntax errors…

NO :frowning:

$data = file_get_contents(“XXXXXXXXX”);
$array = json_decode($data, true);
echo array_column();

No correct

Does it work !

<?php $data = file_get_contents("https://graph.facebook.com/205698738221/videos?fields=titre&access_token=######EMPTY-CODE##########"); $array = json_decode($data, true); if(is_array($array) ) { echo $array['id']; }else { echo ' empty data';} ?>

The words look like they try to introduce a question, but the character in the end tends to make a definitive statement.

But at least that has nothing to do with the JSON above, nor with selecting multiple values.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service