hey there.... im trying to get a string from an input URL... i want to match a string starting with a hockey players name and then copy everything in that string until the next players name
what i have so far will find the players name and output the name
<?php
// player to serach for
$searchtext = "HEMSKY, ALES";
// season to search in
$season = "20062007";
$counter = 0;
$names = array();
for ($m = 1; $m <= 25; $m++)
{
$url = "http://www.nhl.com/scores/htmlreports/".$season."/ES0".($m + 20000).".HTM";
$str = file_get_contents($url);
// test to see if the $searchtext (players last name) is found in the string from the URL
if (strpos($str, $searchtext) > 0)
{
if (preg_match("/$searchtext/", $str, $array))
{
// copy each returned string into the names array
$names[$counter] = $array[0];
}
$counter++;
}
}
// print out array contents
$array_count = count($names);
for($i = 0; $i <= $array_count; $i++)
{
print $names[$i];
echo "<br>";
}
?>
but when i change the regex to to anything else, it stops working.... even if i chance it to: if (preg_match("/$searchtext./", $str, $array)) it stops working.... shouldnt the . just allow for any other character other than newline?