Replace strings in php -
i have string consists of tags <p> </p>
, want replace them <br />
, whenever try using str_replace()
not so.
is there solution it? other possible way it?
$string="<p> 1 para </p> <p> second </p>";
using:
str_replace("</p> <p>","<br />",$string> nothing gets replaced.
are looking this?
<?php $string = "<p> 1 para </p> <p> second </p>"; $searcharray = array( '<p>' , '</p>' ); $replacearray = array( '' , '<br />' ); var_dump( str_replace($searcharray, $replacearray, $string) ); ?>
output
string(47) " 1 para <br /> second <br />"
Comments
Post a Comment