This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
i know that many have asked for help regarding "undefined offset: 0" and i think i know what it means (no value at this position) but i cant figure out why i get this error.
i want to use a txt filled with youtube ids and get the titles back. It works without a problem if i type in the ids directly, but if i use the variable $video_id i get the error "undefined offset: 0"
<?php
$ids = file("ids.txt");
for($i=0;$i<count($ids);$i ){
$video_id = $ids[$i];
$api_key = 'MY_API_KEY';
$api_url = '
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id='.$video_id.'&key=
'.$api_key;
$data = json_decode(file_get_contents($api_url));
echo $data->items[0]->snippet->title;
echo $video_id;
}
?>
Can someone help and tell me why that doesnt work?
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PHPhelp/com...