p
我有一个很长的 HTML 文本,我想在其中迭代PHP 中标签的id 值。我的原始字符串:
$mystring="
<p> my very long text with a lot of words ....</p>
<p></p>
<p> my other paragraph with a very long text ...</p>
(...)
";
我想要的结果:
$myparsestring= "
<p id=1>my very long text with a lot of words ....</p>
<p id=2> my other paragraph with a very long text ...</p>
";
如您所见,我可以使用getElementsByTagName ()
和正则表达式(可能会拆分)。
您对这项工作有何指导?