1

这是我的PHP。它通过一堆 URL 来获取类似的数据(来自棒球运动员资料的当前本垒打)。但是,我得到“允许的内存大小耗尽”,这让我认为 PHP 只是在聚合所有这些 load_file 数据,即使在我使用 $html->find 来获取我想要的数据之后也是如此。在我已经回显出我需要的内容后,如何告诉 PHP 停止使用来自 load_file 的数据?

include('simple_html_dom.php');

        $json = file_get_contents("http://example.com/homeruns.json");

        $elements = json_decode($json);

        foreach ($elements as $element){
                $html = new simple_html_dom();
                $html->load_file($element->profileurl);
                $currenthomeruns = $html->find('.homeruns .current',0);
                echo $element->name, " currently has the following number of homeruns: ", strip_tags($currenthomeruns); 
        }
4

1 回答 1

1

在循环结束时,执行 unset($html);

于 2013-03-01T00:39:45.500 回答