Advertisement
BrunoDeOliveira

fetchIds.php

Mar 2nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($array)) {
  4.     $videoID = [];
  5.     $sql = "SELECT * FROM youtubelist ORDER BY id DESC LIMIT 5";
  6.     $query = mysqli_query($sql);
  7.     while ($youtubeData = mysqli_fetch_assoc($query)) {
  8.         preg_match(
  9.             '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i',
  10.             $youtubeData,
  11.             $url);
  12.  
  13.         $videoID[] = $url[1];
  14.     }
  15.  
  16.     echo json_encode($videoID);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement