Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress短码循环数据_Php_Html_Wordpress - Fatal编程技术网

Php Wordpress短码循环数据

Php Wordpress短码循环数据,php,html,wordpress,Php,Html,Wordpress,我正试图创建我的第一个wordpress短代码,从一个网站上删除数据并发布。但是,我在用html代码连接php循环,然后返回html时遇到了问题。我想在每次执行循环时创建一行,并将opp1、opp2和score放入表中,然后重新运行html脚本 <table class="match-table" cellspacing="0" cellpadding="0"> <tbody> <tr class="margin-tr"> <

我正试图创建我的第一个wordpress短代码,从一个网站上删除数据并发布。但是,我在用html代码连接php循环,然后返回html时遇到了问题。我想在每次执行循环时创建一行,并将opp1、opp2和score放入表中,然后重新运行html脚本

<table class="match-table" cellspacing="0" cellpadding="0">
    <tbody>
   <tr class="margin-tr">
        <td class="match-icon">Icon</td>
        <td class="match-home">Opp1</td>
        <td class="match-score">score</td>
        <td class="match-away">opp2</td>
        <td class="match-time">22:00</td>
    </tr>

    </tbody>
</table>

你能再解释一下你现在的问题吗。您所编写的循环的预期输出是什么?您实际从中得到了什么?
function getGames() {

$html = str_get_html(getHTML($url,10));

    //$title = str_replace(array("\n", "\r"), '',$html->find("/[@id='main']/div[1]/div[2]/div[1]/h2/strong",0)->plaintext);
    //$manuf = $html->find("/[@id='main']/div[1]/div[2]/div[3]/table/tbody/tr[1]/td[2]/strong",0)->plaintext;
$table = $html->find("/[@id='matches_list']/",0);

foreach($table->find("li") as $line){
    $game = $line->find("a/span/img",0)->title;
    if(  $game == "CS:GO" or $game == "Hearthstone" or $game == "Dota 2" or $game == "StarCraft II" or $game == "League of Legends"){

        $opp1 = $line->find("span.opp1",0)->plaintext;
        $opp2 = $line->find("span.opp2",0)->plaintext;
        $score = $line->find("span.score",0)->plaintext;


        }

    }

}

add_shortcode('getGames', 'getGames');