- preg_replace: documentation ( source)
<?php
$val = '<input type="radio" name="alright" id="alright-1" value="1">';
echo preg_replace(
'/<input([a-zA-Z_0-9 ={}"]*)type="radio"([a-zA-Z_0-9 ={}"]*)name="alright"([a-zA-Z_0-9 ={}"]*)value="1">/',
'<input$1type="radio"$2name="alright"$3value="1" checked>',
$html
);