0
Ich habe ein Problem mit dem Einfügen des zuvor definierten PHP-Wertes $ video_url als eines der Array-Mitglieder. Hier der Code:PHP-Wert als Array-Member einfügen?
$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 habe ich etwas Wort durch Einfügen von $ video_url in Array. Vielen Dank.
Versucht ohne Anführungszeichen, das gleiche Ergebnis – MyMadWeb
Sind Sie Ihre Kommentare zu beheben? Entferne '#' und füge '//' hinzu. Kannst du 'var_dump ($ url)' wissen, was drin ist? –
Ich habe Kommentare (und in meinem ursprünglichen Post) behoben. Hier ist var_dump ($ url) Ergebnis: array (2) { [0] => string (17) "https://youtu.be/9bZkp7q19f0" [1] => string (43) "https://www.youtube.com/watch?v=e-ORhEE9VVg" } – MyMadWeb