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条)

报告相同问题?