memory - How do I tell PHP to get rid of load_file data after it's used?


Here is my PHP. It runs through a bunch of URLs to get similar data (current homeruns from baseball player profiles). However, I'm getting 'Allowed memory size exhausted', which leads me to think that PHP is just aggregating all this load_file data, even after I've used $html->find on it to get the data I want. How can I tell PHP to stop using data from load_file after I've already echo'ed out what I need?


        $json = file_get_contents("");

        $elements = json_decode($json);

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



at the end of your loop, do unset($html);

People are also looking for solutions to the problem: php - Array being replaced rather than added


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.