Last active
August 29, 2015 14:07
-
-
Save kaja47/c88bd5cb1b8bea1994b1 to your computer and use it in GitHub Desktop.
Matcher examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$m = Matcher::multi('//table[@id="egmFixtureList"]/tr[@class]', [ | |
'datum' => 'td[@colspan]', | |
'spielnr' => 'td[1]', | |
'anpfiff' => 'td[2]', | |
'team1' => 'td[3]/a/text()', | |
'team2' => 'td[5]/a/text()', | |
'spielbericht' => 'td[7]/a/@href', | |
])->fromHtml()->map(function ($rows) { | |
$datum = null; | |
foreach ($rows as $i => & $row) { | |
if ($row['datum']) { | |
$datum = $row['datum']; | |
unset($rows[$i]); | |
} else { | |
$row['datum'] = $datum; | |
} | |
} | |
return $rows; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$m = Matcher::multi('//table[@id="egmFixtureList"]/tr[@class and not(td[@colspan])]', [ | |
'datum' => 'preceding-sibling::tr[td[@colspan]][1]', | |
'spielnr' => 'td[1]', | |
'anpfiff' => 'td[2]', | |
'team1' => 'td[3]/a/text()', | |
'team2' => 'td[5]/a/text()', | |
'spielbericht' => 'td[7]/a/@href', | |
])->fromHtml(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment