\", so that when i want to edit this field, the \"< br />\" will not be appeared?" />
开发者

strip <br>(n12br) get from database field

开发者 https://www.devze.com 2023-03-08 21:14 出处:网络
i have a textarea value which its value derived from a field(nl2br) how to strip off \"< br/>\", so that when i want to edit this field, the \"< br />\" will not be appeared?

i have a textarea value which its value derived from a field(nl2br)

how to strip off "< br/>", so that when i want to edit this field, the "< br />" will not be appeared?

//$data["Content"] is the field that has <br/> tags inside
$content = $data["Content"];

//when want to edit, want to strip the <br/> tag
<td><textarea name="content" rows="10" style="width:300px;"><?=$conten开发者_C百科t?></textarea></td>

i know it should be using strip_tags() function but not sure the real way to do it

any help would be appreciated


If you wanna use strip_tags, then it would just be:

$content = strip_tags($data["Content"]);


i would be using str_replace the following will replace <br/> with newline

$content = str_replace('<br/>','\n',$data['Content']);

or if you don't want the newline

$content = str_replace('<br/>','',$data['Content']);

edit an example

$my_br = 'hello<br/> world';
$content = str_replace('<br/>','',$my_br);

echo $content;

Output: hello world
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号