PHP如何在给定字符串中查找出特定两个字符之间的内容?
查询的 ip:219.245.125.100 来自:陕西省西安市 西安电子科技大学
GeoIP: Xidian, China
您今日已查询 14 次,最多可查 100 次。
如上,想获取“来自:”和"
GeoIP:"之间的“陕西省西安市 西安电子科技大学”,该如何处理?
------解决方案--------------------
立即学习“PHP免费学习笔记(深入)”;
- PHP code
$s=<<<div<div class="well"><p>查询的 IP:<code>219.245.125.100</code> 来自:陕西省西安市 西安电子科技大学</p><p>GeoIP: Xidian, China</p><p></p><p>您今日已查询 14 次,最多可查 100 次。</p></div>div;preg_match('/来自:(.*?)<\/p><p>/',$s,$m);echo $m[1];<br><font color="#e78608">------解决方案--------------------</font><br>将给定字符串保存在$current0中<br><br>$current='<<<div'.$current0.'div';<br>preg_match('/来自:(.*?)<\/p><p>/',$current,$result);<br>echo $result[1];<div class="clear">
</div>











