Hi guys, I need some help on preg_matching the following segment of data:
td class="ghr-c" nowrap>2004</td> <td class="ghr-c" nowrap>2003</td> <td class="ghr-c" nowrap>2002</td> <td class="ghr-c" nowrap>2001</td> <td class="ghr-c" nowrap>2001</td> <td class="ghr-c" nowrap>2000</td> <td class="ghr-c" nowrap>2000</td> <td class="ghr-c" nowrap>2000</td> <td class="ghr-c" nowrap>1999</td> <td class="ghr-c" nowrap>1999</td> <td class="ghr-c" nowrap>1999</td> <td class="ghr-c" nowrap>1998</td> <td class="ghr-c" nowrap>1998</td> <td class="ghr-c" nowrap>1997</td> <td class="ghr-c" nowrap>1997</td> <td class="ghr-c" nowrap>1996</td> <td class="ghr-c" nowrap>1996</td> <td class="ghr-c" nowrap>1995</td>
</tr>
I used the following function:
function scrape ($string){
$pattern = "/nowrap>(.*?)<\/td>/i";
preg_match($pattern, $string, $match);
print_r($match);
}
however, when I print_r the $match array, all I get is one match:
Array ( [0] => nowrap>2004[1] => 2004 )
I am just wondering how I can get all the dates into a $match array so that I can put each into a SQL table. Can you guys please tell me what's wrong with my code or can you guys please suggest me another approach to my problem?
Thanks a lot in advance!!
Andrew