如何在 foreach 中添加多个质量
How do I add more than one quality inside a foreach
foreach($div->getElementsByTagName('a') as $link) {
$url = $link->getattribute('href');
$num = $link->nodeValue;
echo '<source src="'.$url.'" type="video/mp4" label="----quality----" />';
}
视频link重复了5次..我想给每个视频都加画质[240-360-480-720-1080]..找了很多也没找到解决办法我的问题,我希望有一个例子
使用 foreach
中的索引,然后将其用作质量数组的索引。
$qualities = [240, 360, 480, 720, 1080];
foreach($div->getElementsByTagName('a') as $index => $link) {
$url = $link->getattribute('href');
$num = $link->nodeValue;
$quality = $qualities[$index];
echo '<source src="'.$url.'" type="video/mp4" label="----' . $quality . '----" />';
}
foreach($div->getElementsByTagName('a') as $link) {
$url = $link->getattribute('href');
$num = $link->nodeValue;
echo '<source src="'.$url.'" type="video/mp4" label="----quality----" />';
}
视频link重复了5次..我想给每个视频都加画质[240-360-480-720-1080]..找了很多也没找到解决办法我的问题,我希望有一个例子
使用 foreach
中的索引,然后将其用作质量数组的索引。
$qualities = [240, 360, 480, 720, 1080];
foreach($div->getElementsByTagName('a') as $index => $link) {
$url = $link->getattribute('href');
$num = $link->nodeValue;
$quality = $qualities[$index];
echo '<source src="'.$url.'" type="video/mp4" label="----' . $quality . '----" />';
}