Home > Backend Development > PHP Tutorial > 字符串查找功能

字符串查找功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:01:42
Original
959 people have browsed it

大家好:
  想请教一下
   现在有这样的一段输出
   "我在

上海

的浦东

某地

"
   通过什么办法可以获取

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

   上海
   某地
以上,谢谢

回复讨论(解决方案)

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

Array
(
[0] => 上海
[1] => 某地
)

$s = "我在<h2>上海</h2>的浦东<h2>某地</h2>";preg_match_all('#<h2>(.+?)</h2>#', $s, $r);print_r($r[1]);
Copy after login
Array
(
[0] => 上海
[1] => 某地
)

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

Array
(
[0] => 上海
[1] => 某地
)
万分感谢


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

Array
(
    [0] => 上海
    [1] => 某地
)
万分感谢 谢谢

Related labels:
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