See the below list of options, i am trying to get value of option which is selected.
<select>
<option {class='test'} value="volvo" selected='selected'>Volvo</option>
<option {class='test'} value="saab">Saab</option>
<option {class='test'} value="mercedes">Mercedes</option>
<option {class='test'}value="audi">Audi</option>
</select>
in the above example i need to get volvo as the matched string. there may or may not have any class parameter. That's if option string is
<option {class='test'} value="volvo" selected='selected'>Volvo</option>
or
<option value="volvo" selected='selected'>Volvo</option>
Regular expression should return volvo. That's a regular expression suitable for all cases.
I tried with
preg_match_all('/<option\sclass="[^"]*"\svalue="([^"]*)">([^>]*)<\/option>/', $string, $matches);`
But that didn't return value of the selected item. Please help.