在第423行上的非对象上调用成员函数find()

时间:2014-02-11 00:06:49

标签: php arrays simple-html-dom

我收到错误

  

在第423行的非对象上调用成员函数find()。

我知道有一个url作为数组中的键,因为我测试并工作。之前也使用了423上的代码行并且工作正常。

以下是代码示例

$oppo_team = array(teams::$ars_fixtures=>'Arsenal', teams::$manc_fixtures=>'Manchester City', teams::$che_fixture=>'Chelsea', teams::$liv_fixture=>'Liverpool', teams::$tott_fixture=>'Tottenham', teams::$eve_fixture=>'Everton', teams::$manu_fixture=>'Manchester United', teams::$newc_fixture=>'Newcastle United',
    teams::$south_fixture=>'Southampton', teams::$swan_fixture=>'Swansea City', teams::$ast_fixture=>'Aston Villa', teams::$nor_fixture=>'Norwich City', teams::$hull_fixture=>'Hull City', teams::$cry_fixture=>'Crystal Palace', teams::$westb_fixture=>'West Bromwich Albion', teams::$stoke_fixture=>'Stoke City',
    teams::$westh_fixture=>'West Ham United', teams::$ful_fixture=>'Fulham', teams::$sun_fixture=>'Sunderland', teams::$carc_fixture=>'Cardiff City');


 for ($i=0; $i < $lengthgp; $i++) { 
# code...
    if(!preg_match('/'.$home_team[$i].'/i', $team)){
        if($i == 0){

        }else if($i > 0){

        }

    }else{}

    if(!preg_match('/'.$away_team[$i].'/i', $team)){
        if($i == 0){

        }else if($i > 0){
        echo $oppaway[] = array_search($away_team[$i], $oppo_team);
            //}else{

            //}

            $oppfix = file_get_html($oppaway);

            //Collect scores from the sites table

            for($score = 1;$score<114;$score+=3){
            // Find within td a
    LINE 423---->   $oppa_scores = $oppfix->find('td a', $score);
            //store in array
                $oppgame_scores[] = $oppa_scores->plaintext;
            }

添加键是单独类上的链接的数组。

3 个答案:

答案 0 :(得分:0)

如果$oppaway是您的网址,请更改

echo $oppaway[] = array_search($away_team[$i], $oppo_team);

echo $oppaway = array_search($away_team[$i], $oppo_team);

file_get_html的参数应为字符串

答案 1 :(得分:0)

您是否使用包含“find”方法的类实例化了$ oppfix?

答案 2 :(得分:0)

我发现有时在simple_html_dom中你需要检查是否有可用的网址,即使它有一个如果不存在会发生什么。

$oppfix = file_get_html($oppaway);

if(!exist($oppfix)){

        //Collect scores from the sites table

        for($score = 1;$score<114;$score+=3){
        // Find within td a
LINE 423---->   $oppa_scores = $oppfix->find('td a', $score);
        //store in array
            $oppgame_scores[] = $oppa_scores->plaintext;
        }
}else{
//Do SOMETHING
}