- preg_match: documentation ( source)
- preg_replace: documentation ( source)
<?php
$oldstr1='<span style="font-family: Times New Roman; font-size: 12pt;">';
$oldstr2='</span>';
$newstr1='<input type="radio" value="1" name="choice">';
$newstr2="</input>";
$str='<span style="font-family: Times New Roman; font-size: 12pt;"></span>';
while (preg_match($oldstr1, $str) && preg_match($oldstr2, $str)) {
$str = preg_replace($oldstr1,$newstr1, $str, 1);
$str = preg_replace($oldstr2,$newstr2, $str, 1);
}
echo $str;