dongza1708 2016-05-15 15:43
浏览 28
已采纳

在PHP中过滤字符串

I'm looking to get an array of ID's from the following string.

[vc_gallery type="flexslider_fade" interval="3" images="3057,2141,234" onclick="link_image" custom_links_target="_self" img_size="large"]

Ideally, i'd like to look at this string and get an array of the INT values within images. e.g.

array("3057", "2141", "234");

  • 写回答

2条回答 默认 最新

  • dongteng0748 2016-05-15 15:49
    关注

    find images value and explode it to receive array

    $str = '[vc_gallery type="flexslider_fade" interval="3" images="3057,2141,234" onclick="link_image" custom_links_target="_self" img_size="large"]';
    
    if (preg_match('/images\s*=\s*\"([^\"]+)\"/', $str, $m)) {
       $res = explode(',', $m[1]);
       print_r($res);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试