-4
<ul class="c2">
    <li><a href="hire-project-manager/">Hire Project Manager </a></li>
    <li><a href="hire-ios-developer/"> Hire iPhone Developer </a></li>
    <li><a href="hire-ios-developer/">  Hire iPad Developer </a></li>
    <li><a href="hire-android-developer/">Hire Android Developer </a></li>
    </li>
    <li><a href="hire-3d-artist/">Hire 3D Artist</a></li>
</ul>
</div>
<h1>Get In Touch With Us</h1>
<div class="copyright-footer">Copyright &copy; All rights reserved  </div>

私はこれらのhtmlをフォローしており、余分なスペースを削除したいので、次のような結果が必要です:

<ul class="c2">
    <li><a href="hire-project-manager/">Hire Project Manager</a></li>
    <li><a href="hire-ios-developer/">Hire iPhone Developer</a></li>
    <li><a href="hire-ios-developer/">Hire iPad Developer</a></li>
    <li><a href="hire-android-developer/">Hire Android Developer</a></li>
    </li>
    <li><a href="hire-3d-artist/">Hire 3D Artist</a></li>
</ul>
</div>
<h1>Get In Touch With Us</h1>
<div class="copyright-footer">Copyright &copy; All rights reserved</div>

PHPとpreg、str_replaceなどの助けを借りて、これを解決するのを手伝ってくれる人はいますか

4

1 に答える 1

0

[\n\t\r\ ]タグ開始後のテキストの開始から 空白を削除します。

$html=preg_replace('/>\s+/','>',$html);

[\n\t\r\ ]タグの前のテキストの末尾から 空白を削除します。

$html=preg_replace('/\s+</','<',$html);
于 2013-01-30T16:03:29.460 に答える