Home > Backend Development > PHP Tutorial > 求一段正则表达式,该怎么处理

求一段正则表达式,该怎么处理

WBOY
Release: 2016-06-13 13:40:11
Original
1002 people have browsed it

求一段正则表达式


     

  •  
       求一段正则表达式,该怎么处理

     

    [淘宝商城]


     

    活动标题


     

  •  

  •   ……
     


  • ……




      我希望通过正则 将上面的内容 变成一串数组

      array(
        [0] =>array(
        "shopname" => "淘宝商城",
        "activename"=> "活动标题",
        "actimage" => "http://image.com/pic.gif", 
        "acturl" => "http:/www.tmall.com/" //这个是活动标题的链接
        ),
        [1] =>array(……)
        ……
      );

      就像上面一样输出数组  



      ------解决方案--------------------
      只用正则达到你的要求似乎不太可能。要处理一下。我贴下匹配结果。处理自己补充:
      PHP code
      
         $str=
        
      Copy after login
    •  求一段正则表达式,该怎么处理

      [淘宝商城]

      活动标题

    • ……
    • …… HTML; /** *"shopname" => "淘宝商城", "activename"=> "活动标题", "actimage" => "http://image.com/pic.gif", "acturl" => "http:/www.tmall.com/" //这个是活动标题的链接 */ $pattern = '~img.*(?'; print_r($res); echo ''; /** 剩下的你懂的 Array ( [0] => Array ( [0] => http://image.com/pic.gif1 [1] => 淘宝商城1 [2] => http://www.tmall.com/1 [3] => 活动标题1 ) [1] => Array ( [0] => http://image.com/pic.gif2 [1] => 淘宝商城2 [2] => http://www.tmall.com/2 [3] => 活动标题2 ) ) */
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template