Parsing help needed, regular expression perhaps?
| From: | Jeff Lewis | Date: | Wed, 12 Mar 2003 17:19:18 +0000 |
| Subject: | Parsing help needed, regular expression perhaps? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-139339@lists.php.net to get a copy of this message | ||
I am grabbing this page and trying to grab the stats on the page: http://slam.canoe.ca/StatsHKN/BC-HKN-STAT-TORONTOSTAX-R.html
The code I had worked just fine before but now that there are players that have multiple lines,
it's not working as I'd like it to. Below is the code that worked and I need help to get
it to ignore the lines of players from other teams and just get thheir total number.
$statsURL = "http://slam.canoe.ca/StatsHKN/BC-HKN-STAT-TORONTOSTAX-R.html";
$season = "2002-03R";
$urlHandle = fopen("$statsURL", "r");
if (!$urlHandle) {
echo "$errstr ($errno)<br>\n";
exit;
}
$rawHtml = fread($urlHandle,1000000);
fclose($urlHandle);
$rawHtml = stristr($rawHtml, "<pre>");
$stats = substr($rawHtml, 0, strpos($rawHtml, "</pre>")-1);
$playerline = preg_split("/\n/", $stats, -1, PREG_SPLIT_NO_EMPTY);
$count = count($playerline);
echo "Players: $count<P>";
for ($x = 0; $x <= $count; $x++) {
$playerstats = preg_split("/[ ]/", $playerline[$x], -1, PREG_SPLIT_NO_EMPTY);
}