1

私はphp Querypathを使用しており、htmlの上下にあるすべての空のタグをhtml文字列から削除しようとしています。例えば:

      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div>I want remove empty div tag on top and bottom</div>
      <div>&nbsp;</div>
      <div>other content</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>

php querypath を使用すると、次のように変更できます。

      <div>I want remove empty div tag on top and bottom</div>
      <div>&nbsp;</div>
      <div>other content</div>

どのようにできるのか?

4

1 に答える 1

0

文字列の置換を使用して、divを空のスペースに置き換えます。

str_replace(find,replace,from);

したがって、<div>&nbsp;</div>in findを使用して、コードからそれを置き換えることができ""ます。

于 2012-11-17T14:29:08.927 に答える