I want to replace with For example I have this one:
<textarea type="text" style="height: 30px; width: 144px;" name="a" id="a" value=""/>
and I want it to become:
<textarea type="text" style="height: 30px; width: 144px;" name="a" id="a" value=""></textarea>
I using this regular expression:
preg_replace('!<textarea.*/>!', '<textarea.*></textarea>', $text);
but is not working. I am quite new to regular expressions so it would be very nice if someone could help me with this. Thanks in advance
<?php
$text = '<textarea type="text" style="height: 30px; width: 144px;" name="a" id="a" value=""/>';
$text = preg_replace('/<textarea(.*?)\/>/',
'<textarea$1></textarea>', $text);
print $text;
Prints:
<textarea type="text" style="height: 30px; width: 144px;" name="a" id="a" value=""></textarea>
$try this code:
$s= '<textarea type="text" style="height: 30px; width: 144px;" name="a" id="a" value=""/>';
echo $a= str_replace("/>","></textarea>",$s);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.