2020-11-17 14:46:41
php的str_replace函数怎么把<p><br/></p>替换掉方法如下
$html="<p>fdasf</p>";
echo $string = str_replace(array("<p>","","</p>"),"",$html);
br<
若是<p> 内容</p>替换成<p>内容</p>
<p> content</p>替换成<p>contend</p>
(空格是tab键和空格键 混合的 都有可能)方法如下
$html=preg_replace('/[\n\r\t]/','',$html);//去空格
若是<p>后面跟了若干个,再是内容
<p> 内容</p>
替换成<p>内容</p>
<p> content</p>
替换成<p>contend</p>
<?php
$html="<p>
内容</p>替换成<p>内容</p>
<p>content</p>替换成<p>contend</p>";方法如下
$html=trim($html);
$html=str_replace(PHP_EOL,"",$html);
$html=str_replace(" ","",$html);
$html=preg_replace('/\s+/','',$html);
$html=preg_replace('/[\n\r\t]/','',$html);
echo "{$html}";
?>
2024-01-26 15:13:27
2023-03-11 21:56:04
$html="<p><br/>fdasf</p>";
echo $string = str_replace(array("<p>","<br/>","</p>"),"",$html);
br被和谐了
2024-03-28 01:32:27
2023-12-31 03:02:23
<?php
$vowels = array("<p>", "<br/>", "i", "</p>");
$onlyconsonants = str_replace($vowels, "", $str);
?>