How do I extract specific data with preg_match?

Posted by paulswansea on Stack Overflow See other posts from Stack Overflow or by paulswansea
Published on 2010-03-19T08:32:00Z Indexed on 2010/03/19 8:41 UTC
Read the original article Hit count: 157

Filed under:
|

I'm looking to extract values from a whole load of html (i've just trimmed down to the relevant data), there are multiple 'select' elements, and only want to extract those who's 'name' element matches the name 'aMembers'. So the resulting values I would like to retrieve are 5,10,25 and 30 (see below) how can I achieve this with preg_match?

    <DIV id="searchM" class="search"><select name="aMembers" id="aMembers" tabIndex="2">
    <option selected="selected" value="">Data 3</option>
    <option value="5">A name</option>
    <option value="10">Another name</option>
</select>
</DIV>
<DIV id="searchM" class="search"><select name="bMembers" id="bMembers" tabIndex="2">
    <option selected="selected" value="">Data 2</option>
    <option value="15">A name</option>
    <option value="20">Another name</option>
</select>
</DIV>
<DIV id="searchM" class="search"><select name="aMembers" id="Members" tabIndex="2">
    <option selected="selected" value="">Data 1</option>
    <option value="25">A name</option>
    <option value="30">Another name</option>
</select>
</DIV>

© Stack Overflow or respective owner

Related posts about php

Related posts about preg-match