0

need matched 2 string and add < p > tag after matched string, for example;

$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";

i need string 1 output will be remain same with all include of HTML tags.

4

1 回答 1

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);
于 2013-11-06T07:54:06.163 回答