PHP 简单 HTML DOM 带有值拆分的解析器

PHP Simple HTML DOM Parser with a value split

我正在使用 PHP 简单 HTML DOM Parser 从网站上抓取一些值。 我已经拆分了一个名为$results的变量(格式为:number:number) 使用 .str_replace 但我需要分别使用 $results 中的这两个数字。 这是我的代码:

require_once '../simple_html_dom.php';

$html = file_get_html('http://www.betexplorer.com/soccer/belgium/jupiler-league/results/');

$match_dates = $html->find("td[class=last-cell nobr date]"); // we have 1 per match
$titles = $html->find("td[class=first-cell tl]"); // 1 per match
$results = $html->find("td[class=result]"); // 1
$best_bets = $html->find("td[class=odds best-betrate]"); // 1
$odds = $html->find("td[class=odds]"); // 2

$c = $b = 0; // two counters

foreach ($titles as $match) {
    echo $match_dates[$c]->innertext." - ".$match->innertext." ".str_replace(':',' ',$results[$c]->innertext)." - ".$best_bets[$c++]->attr['data-odd']." / ".$odds[$b++]->attr['data-odd']." / ".$odds[$b++]->attr['data-odd']."<br/>";
}

所以我需要分别使用 $results 中的这两个数字,并且我想将所有值插入到 table 中。
谢谢

正如@splash58 已经在评论中提到的,您必须使用 explode 轻松分隔两个值。

foreach ($titles as $match) {
    list($num1, $num2) = explode(':', $results[$c]->innertext); // <- explode
    echo $match_dates[$c]->innertext .
         " - ".$match->innertext." ".$num1.':'.$num2 .          // <- example use
         " - ".$best_bets[$c++]->attr['data-odd'] .
         " / ".$odds[$b++]->attr['data-odd'] .
         " / ".$odds[$b++]->attr['data-odd'] .
         "<br/>";
}