PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Where "visitor" and "home" are different team names of different lengths. And blah is the location of the game. The string also includes all of the whitespace shown. The way I am doing it now, I just echo the string inside <pre> tags which is not very stylish. I would like to assign variables for the date, time, team, and location. Does anyone have any idea how I can accomplish this?
<?php
$s ="^"; // Starts the regex
$s ="([0-9]{2})/([0-9]{2})/([0-9]{2})"; // Dates
$s.="\s+([0-9]{4})"; // Time in European format
$s.="\s+([ \w]+).+"; // First team
$s.="\s+([0-9]+)"; // First Team Score
$s.="\s+([ \w]+).+"; // 2nd team
$s.="\s+([0-9]+)"; // 2nd Team Score
$s.="\s+\\(at ([/w .,]+)\\)\s+"; // Venue
?>
I don't guarantee that it'll work, but it's a step in the right direction.
<?php
$s ="^"; // Starts the regex
$s ="([0-9]{2})/([0-9]{2})/([0-9]{2})"; // Dates
$s.="\s+([0-9]{4})"; // Time in European format
$s.="\s+([ \w]+).+"; // First team
$s.="\s+([0-9]+)"; // First Team Score
$s.="\s+([ \w]+).+"; // 2nd team
$s.="\s+([0-9]+)"; // 2nd Team Score
$s.="\s+\\(at ([/w .,]+)\\)\s+"; // Venue
preg_match($s, $html, $match);
$output = $match[0];
print $output;
?>
<?php
$s ="^"; // Starts the regex
$s.="([0-9]{2})/([0-9]{2})/([0-9]{2})"; // Dates // Changed this to .= instead of =
$s.="\s+([0-9]{4})"; // Time in European format
$s.="\s+([ \w]+).+"; // First team
$s.="\s+([0-9]+)"; // First Team Score
$s.="\s+([ \w]+).+"; // 2nd team
$s.="\s+([0-9]+)"; // 2nd Team Score
$s.="\s+\\(at ([/w .,]+)\\)\s+"; // Venue
$s.="^"; // Ends the regex // Added this
?>
If that doesn't fix it, change the appropriate line with...