从文件/字符串/ URL获取Div的值 [英] Getting Div's value from a File/String/URL

查看:61
本文介绍了从文件/字符串/ URL获取Div的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiya家伙,


在提问之前让我告诉你我在正则表达式(REGEX)上真的很糟糕:(


嗯首先,我想获得具有特定id的div内的值。

一个例子可以是


[HTML]< div id = 静态>

这是我想要获取的内容,当我将这整个文件以字符串格式从file_get_contents获取时

< / div>

[/ HTML]


我希望我的问题清楚,请让我知道我该怎么做?


谢谢:)

干杯!!

解决方案




[php]

preg_match(''/< div id = \""。


id。" \">( 。*)< / DIV> / '',

串,

hiya guys,

Before asking question let me tell you i am really bad at regular expressions (REGEX) :(

Well to start with, i want to get the value inside a div with a particular id.
An example can be

[HTML]<div id="static">
This is the content i want to fetch, When i have this whole file in the string format which i got it from file_get_contents
</div>
[/HTML]

I hope i made my question clear, please let me know how can i do that ?

Thanks :)
Cheers !!

解决方案

Would

[php]
preg_match(''/<div id=\"".


id."\">(.*?)</div>/'',


string,


这篇关于从文件/字符串/ URL获取Div的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆