I'm having a problem with inserting previously defined PHP value $video_url as one of the array members. Here the code:
$video_url= "[[+virtual_tour]]"; /* [[+virtual_tour]] is MODX placeholder which contains first video url */
echo $video_url; /* for test reasons. Outputs https://youtu.be/9bZkp7q19f0 */
$url = array(
'$video_url', /* URL of the first video */
'https://www.youtube.com/watch?v=e-ORhEE9VVg' /*URL of the second video */
);
// Extracts the YouTube ID from various URL structures
foreach ($url as $value) {
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $value, $match)) {
$id = $match[1];
echo $id; /* outputs only ID of second video, but not first */
}
}
So I have something word by inserting $video_url into array. Thanks.