需要匹配2个字符串并添加< p>匹配字符串后的标记,例如;
$string1="<p>he adventures <p>
<p>of < span >adolescence< /span > had taught Piet < span >Barol< /span > that he</p>";
$matching_with_string="he adventures
of adolescence had
taught Piet Barol
that he";
我需要字符串1输出与所有HTML标记包含相同。
答案 0 :(得分:0)
你可以试试这样的事情
<?php
$strWithHTML="<p>he adventures <p>
<p>of < span >adolescence< /span > had taught Piet < span >Barol< /span > that he</p>";
$strWITHOUTHTML=str_replace(array('< ','/',' >','span'),'',strip_tags($string1));
编辑:
我想结果将是HTML格式
<?php
$strWithHTML="<p>he adventures <p>
<p>of < span >adolescence< /span > had taught Piet < span >Barol< /span > that he</p>";
echo htmlentities($strWithHTML);