php - 如何在没有类和 ID 的 PHP 中获取 div 内容

标签 php html css

我在 php(string) 中有一个 div,我想获取内容。

例如——

<div style="text-align:right;">
      <div>
       bla bla bla
      </div>
      bla bla          
</div>

我想要——

<div>
     bla bla bla
</div>
     bla bla

我没有 div id 或 class

最佳答案

对于此类任务,您可以使用 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

关于php - 如何在没有类和 ID 的 PHP 中获取 div 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17378251/

相关文章:

php - 通过 POST 提交时删除某些字符

javascript - Bootstrap Overlay 图像没有响应

javascript - 我如何只劫持 LI 中的一个特定链接而不是所有链接?

html - html 中的行更改 css

html - 悬停时 Glyphicon 改变颜色

php - WordPress 网站已将我的链接重定向到 onclickads 网站

php - 如何使用存储在变量中的类名创建新对象以及如何将另一个变量传递给此类的构造函数?

PHP 没有显示任何值,但肯定会传递值

javascript - 如何删除移动应用程序中的多余空间?

php - HTML 邮件显示空白消息