Home > Backend Development > PHP Tutorial > 字符串查找功能,该怎么处理

字符串查找功能,该怎么处理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:49:29
Original
762 people have browsed it

字符串查找功能
大家好:
  想请教一下
   现在有这样的一段输出
   "我在

上海

的浦东

某地

"
   通过什么办法可以获取

标签中的内容?
   希望输出的结果是

   上海
   某地
以上,谢谢

------解决方案--------------------
$s="我在<h2>上海</h2>的浦东<h2>某地</h2>";<br />preg_match_all('#<h2>(.+)</h2>#U',$s,$m);<br />print_r($m[1]);
Copy after login

Array
(
[0] => 上海
[1] => 某地
)
------解决方案--------------------
$s = "我在<h2>上海</h2>的浦东<h2>某地</h2>";<br /><br />preg_match_all('#<h2>(.+?)</h2>#', $s, $r);<br />print_r($r[1]);
Copy after login
Array
(
    [0] => 上海
    [1] => 某地
)
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