Voila mon problème :
et voici mon code :Notice: Undefined offset: 25 in C:\wamp64\www\joo\components\com\View\Books\tmpl\item.php on line 258
celui-ci fonctionne bien lorsqu'il trouve un résultat.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <!-- Je recherche les video Youtube--> <?php $video_title = $basic['title']->value; $trouve3=true; if ($video_title != '' && $basic['support']->value == "Vidéo") { $search_youtube =file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet®ionCode=fr&maxResults=25&q=".urlencode($video_title)."&key=AIzaSyAuz"); $search_youtubej =json_decode($search_youtube,true); for ($i = 0; $i <= 25; $i++) { $youtubeTitle = $search_youtubej['items'][$i]['snippet']['title']; if(stristr($youtubeTitle,'bande annonce')||strstr($youtubeTitle,'bande-annonce')) { $trouve3=true; $youtubeID = $search_youtubej['items'][$i]['id']['videoId']; $youtubeDescription = $search_youtubej['items'][$i]['snippet']['description']; break; } else { $trouve3=false; } } }
Mais s'il ne trouve rien j'ai un undefined offset. cela n'est pas gênant mais je souhaiterais le faire disparaitre.
Pouvez-vous m'aider ?
pour info voici la ligne 258:
Code : Sélectionner tout - Visualiser dans une fenêtre à part $youtubeTitle = $search_youtubej['items'][$i]['snippet']['title'];
Partager