Rumah >pembangunan bahagian belakang >tutorial php > 字符串截取解决方案
字符串截取
$subject = '<div class="superStar" id="test_0"><br /> you dead!<br /> <div class="show">hello</div><br /> <span>james</span><br /> </div><br /> <div class="superStar" id="test_1"><br /> shit!<br /> <div class="contne">hi</div><br /> <ul><li>list</li></ul><br /> </div>';<br /> <br /> $pattern = '/这里正则如何写/';<br /> preg_match($pattern, $subject, $matches);<br /> print_r($matches);<br /> <br /> $pattern_1 = '/这里正则如何写/';<br /> preg_match($pattern_1, $subject, $matches);<br /> print_r($matches);<br /> <br /> 分别取到结果如下:<br /> 数据一:<br /> you dead!<br /> <div class="show">hello</div><br /> <span>james</span><br /> <br /> 数据二:<br /> shit!<br /> <div class="contne">hi</div><br /> <ul><li>list</li></ul>