duanhuantong8278 2015-12-26 22:48
浏览 90

php从数组中获取2个不同的$字符串

Here is my problem

preg_match_all('#get something#smi',$data,$get);
$get=$get[0];
$bulsay=count($get)-1;
for ($i=0;$i<=$bulsay;$i++){
preg_match_all('#<img src="http://someurl.com/demo/(.*?)"#smi',$get[$i],$vidid);
}

That $vidid is getting 12 ID, but some id are like this

14/07/12/321312491244.jpg

11/07/24/47311532132-0000.png

6 with JPG and 6 with png

that with the jpg is easy to replace for the video id

like this

141121/022227/22121/321312491244.mp4

but this with png need to be edited like this

11222/0742121/2323224/8_47311532132.flv

i try to get only the png urls like this

preg_match_all('#(.*?)-0000.png#smi',$vidid[$i],$png);
 $png=$png[1][0];

after

print_r($png);

i have 6 array and 6 with 11/07/24/47311532132

how can i get only the 6 with 11/07/24/47311532132

???

I try with if eregi png but it gives me the another 6 too

no idea how to fix

  • 写回答

1条回答 默认 最新

  • doujiao4705 2015-12-27 17:32
    关注

    i did it by my self :)

    here how i do it

    After i get $vidid

    if (!strstr($vidid[$i], "jpg")){
     $pngid=$vidid[$i];
         $videoid = substr("$pngid", 0, -9);
    
    }
    else {
         if (!strstr($vidid[$i], "png"))
        $videoid=$vidid[$i];
        $videoid = substr("$videoid", 0, -4);
    
    }
    
    echo "<pre>";
    print_r($videoid);
    

    there i have a clear png and jpg from my $string!

    评论

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退