douyu0845 2011-10-28 22:35
浏览 33
已采纳

没有文件扩展名的PHP数组 - vimeo视频

I finally managed to get the PHP script below to work...but then I found that I actually can't call vimeo video links because they do not have a file extension eg: http://vimeo.com/12345678

The script I'm using loads a slideshow if the file extension is an image file, if it's a flash file it loads the swf, and my idea was to have a vimeo iframe load if the file extension was for example .mov. All of the filenames are in the work.txt file.

I am so confused about what to do! Does anyone have any ideas of what I could add so that this script can load vimeo videos?

      <?php
$photos=file("work.txt");
$img = array('jpg', 'png', 'gif');
$vid = array('mp4', 'mov', 'mpg', 'flv');
$flash = array('swf');
foreach($photos as $image){
$item=explode("|",$image);
if($item[0]==$fields[0]){
$photo=trim($item[1]);
$ext = explode(".", $photo);

if(in_array($ext[1], $img))
{ echo "<div id='slider-wrapper'><div id='slider' class='nivoSlider'><img src='images/work/$photo' alt='' /></div></div>"; }


elseif(in_array($ext[1], $vid))
{ echo "<iframe src='http://player.vimeo.com/video/$photo' width='900' height='500' frameborder='0' webkitAllowFullScreen allowFullScreen></iframe>"; }


elseif(in_array($ext[1], $flash))       
{ echo "<object id='myId' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='900' height='500'><param name='movie' value='$photo' />
            <!--[if !IE]>-->
            <object type='application/x-shockwave-flash' data='$photo' width='900' height='500'>
            <!--<![endif]-->
            <div>
            <h1>Alternative content</h1>
            <p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a></p>
            </div>
            <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
        </object>"; }

  }
}
?>
  • 写回答

1条回答 默认 最新

  • douruocai4111 2011-10-28 23:53
    关注

    You could use the strpos function on the URL.

    eg:

    elseif(strpos($image, 'vimeo.com') !== false)
    

    That will search your string for the text 'vimeo.com'.

    I'm assuming here that $image is the full URL. But it might be $item, I can't really tell from the code you have provided

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本