I have a string "<select><option value = 'LB1'></option></select>"
What I want to do is replace only the <select> with <select name = "somename">. Currently,
i have a preg_replace statement that replaces the </select> statement also. How can I prevent this.
My current code is
$string = "<select><option value = 'LB1'></option></select>"
$pattern = '<select>';
$replacement = "select name = 'somename' ";
$semistring = preg_replace($pattern, $replacement, $string);
echo "$semistring";
The expected result Is
<select name = "somename"><option value = 'LB1'></option></select>
but I get the following result
<select name = "somename"><option value = 'LB1'></option></select name = "somename">