我已經檢查了其他答案,但似乎無法做到以下幾點。請幫助別人:)PHP preg_replace在特定的html評論標籤之間的一切
我想在兩者之間,幷包括具體的HTML刪除一切評論
HTML:
Some HTML that must stay
<!-- START IF USER_ID -->
some html that must go
<!-- END IF USER_ID -->
Some more HTML that's gotta stay
<!-- START IF USER_ID -->
this also needs to go
<!-- END IF USER_ID -->
所以一切都在<!-- START IF USER_ID -->
和<!-- END IF USER_ID -->
之間和自身需要去評論(這顯然是錯的):
"/<!-- START IF USER_ID -->.*?<!-- END IF USER_ID -->/"
結果應該是
Some HTML that must stay
Some more HTML that's gotta stay
感謝您檢查和提前的答案:)
也許它可以幫助http://www.adminhelpline.com/en/ free-scripts/php/string/how-to-replace-text-between-2-tags-with-php – mlwacosmos
@mlwacosmos謝謝你。本來可以接受你的答案。 +1 – Onimusha