PHP strpos嵌入了视频

时间:2013-12-01 18:03:17

标签: php youtube strpos

问题是,此方法仅适用于一个视频。 并且是链接后的文字(http://www.youtube.com/watch?v=ID精彩视频!)然后不起作用。

<?php
                if (strpos($content, 'http://www.youtube.com/watch?v=') !== false) {
                    $content = str_replace("http://www.youtube.com/watch?v=$id", '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>', $content);
                } else if (strpos($content, 'https://www.youtube.com/watch?v=') !== false) {
                    $content = str_replace("https://www.youtube.com/watch?v=$id", '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="https://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/' . $id . '&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>', $content);
                }
    ?>

0 个答案:

没有答案