PHP - displaying results from a different php file

81 Views Asked by At

I have the following which gets links from various sites:

    <?php

       class news{

         public static function data(){
        $feed = new SimplePie();
        $feed->init();
        $feed->set_feed_url(array(

        'www.bbc.co.uk',
        'www.itv.com/news',
        'www.cnn.com'

        ));

        $feed->set_favicon_handler('handler_image.php');
        $feed->init();
        $feed->handle_content_type();

        $arrFeedStack = array();
        foreach ($feed->get_items() as $property):
        $arrFeedStack[$property->get_title()] = $property->get_description();
        endforeach;

            foreach ($arrFeedStack as $item) {
            $property->get_title(); // The title for the l
            $property->get_DATE('g:i');
            //  echo $item . <br />;


        }
     }

   }        
?>

Now i am just trying to get whatever is returned from this to display in my index.php. Does anyone have an idea of how i could do this?

1

There are 1 best solutions below

0
On BEST ANSWER

Just return your data in data() method then get it like this:

require_once('path/to/yourClassFileName.php');
$data=news::data();