我在php(字符串)中有一个div,我想获取内容。
例如 -
<div style="text-align:right;">
<div>
bla bla bla
</div>
bla bla
</div>
我希望 -
<div>
bla bla bla
</div>
bla bla
我没有div id或class
答案 0 :(得分:0)
对于此类任务,您可以使用regular extensions
有用的功能:
preg_filter — Perform a regular expression search and replace
preg_grep — Return array entries that match the pattern
preg_last_error — Returns the error code of the last PCRE regex execution
preg_match_all — Perform a global regular expression match
preg_match — Perform a regular expression match
preg_quote — Quote regular expression characters
preg_replace_callback — Perform a regular expression search and replace using a callback
preg_replace — Perform a regular expression search and replace
preg_split — Split string by a regular expression