Support

Account

Home Forums Add-ons Repeater Field preg_match inside repeater Reply To: preg_match inside repeater

  • I think it should be something like

    
    if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
      echo $match[1];
    }
    

    Unless you are just trying to get the id then it should be something like

    
    if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
       $youtube_id = $match[1];
    }
    

    but you should not be echoing and setting the value at the same time, this will likely just output true no matter what happens in the match echo $youtube_id = $match[1];