Q:

How to echo all video ids using php youtube data api php

Hello friends I want to echo ( print ) only YouTube video ids on screen using php.
here it is my code so  far. can  any one please tell me how to just show videos id nothing else thanks.
<?php
$data = file_get_contents("https://www.googleapis.com/youtube/v3/search?maxResults=5&part=snippet&key=API_KEY");
$array = json_decode ($data,true);
print_r ($array);

A:

I've adjusted the script for you so that it will retrieve the video id.
Tested and working snippet
 <?php
$apiKey = "enter-your-apikey-here";
$data = file_get_contents("https://www.googleapis.com/youtube/v3/search?maxResults=5&part=snippet&key=".$apiKey);
$array = json_decode ($data,true);
foreach($array['items'] as $data) {
     var_dump($data['id']['videoId']); 
}

