Find multiple patterns with a single preg_match_all in PHP

后端 未结 4 476
独厮守ぢ
独厮守ぢ 2021-01-01 04:49

Using PHP and preg_match_all I\'m trying to get all the HTML content between the following tags (and the tags also):

paragraph text

don\'t
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 05:17

    While doable with regular expressions, you could simplify the task by using one of the simpler HTML parser toolkits. For example with phpQuery or QueryPath it's as simple as:

    qp($html)->find("p, ul, table")->text();   // or loop over them
    

提交回复
热议问题