AoR Zeta
01-18-2008, 01:09 AM
I'm using preg_match and preg_match_all on the contents of a file I retrieved using file_get_contents. Sometimes it works fine and sometimes it just refuses to work.
Say the source of the web page has
<tr>
<td>Played</td>
<td class="values">778</td>
</tr>
<tr>
<td class="col1 left">Earned</td>
<td class="col2">49 of 49</td>
</tr>
I do a preg_match
<?php preg_match('/<td class="values">(.*?)<\/td>/', $file, $result); ?>
and it works fine but then I do another
<?php preg_match('/<td class="col2">(.*?)<\/td>/', $file, $result); ?>
and it doesn't work.
Anyone have any ideas? The problem happens with both preg_match and preg_match_all, sometimes when I search for something it works fine and other times it doesn't... it's really annoying. Thanks a lot.
Say the source of the web page has
<tr>
<td>Played</td>
<td class="values">778</td>
</tr>
<tr>
<td class="col1 left">Earned</td>
<td class="col2">49 of 49</td>
</tr>
I do a preg_match
<?php preg_match('/<td class="values">(.*?)<\/td>/', $file, $result); ?>
and it works fine but then I do another
<?php preg_match('/<td class="col2">(.*?)<\/td>/', $file, $result); ?>
and it doesn't work.
Anyone have any ideas? The problem happens with both preg_match and preg_match_all, sometimes when I search for something it works fine and other times it doesn't... it's really annoying. Thanks a lot.