开发者

PHP parsing simple_html_dom

开发者 https://www.devze.com 2022-12-09 03:24 出处:网络
I am stuck with a semi-hard problem with \'simple html dom\' (php class used for html parsing). I\'ve used it many times before so I know how to do simple parsing. PROBLEM:

I am stuck with a semi-hard problem with 'simple html dom' (php class used for html parsing). I've used it many times before so I know how to do simple parsing. PROBLEM:

$k=0;
for ($k = 0; $k < 15; $k++)
{
    $link[$k] = 'www.example.com/' . $test[1][$k];
    print ($link[$k]);
    $test = file_get_html ('$link[$k]');
    echo($test);
}开发者_如何转开发

What is the answer to this?


Variables in string declarations with single quotes are not expanded to the values they represent. So '$link[$k]' is actually the plain value $link[$k]. But actually you don’t need any quotes at all:

$test = file_get_html($link[$k]);


This seems to be the problem:

$test = file_get_html('$link[$k]');

Remove the quotes:

$test = file_get_html($link[$k]);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号