simplepie include a php file with feed list

158 Views Asked by At

I need a little help with simplepie and php. I use this code to echo a multifeed:

<?php
echo SimplePieWP(array(
    'http://feed1',
    'http://feed2',
    'http://feed3',
), array(
    'items' => 5,
));
?>

It works fine, but I want to have the feeds as a list in a different php file as below:

'http://feed1',
'http://feed2',
'http://feed3',

How should I modify the first code to include the php file with the feed array? I tried this but it doesn't work:

<?php
echo SimplePieWP(array(
    include("feed_array.php");
), array(
    'items' => 5,
));
?>

Any ideas? Thanks

1

There are 1 best solutions below

6
On BEST ANSWER

Almost, you can have includes return a value as well:

#feed_array.php
<?php
  return [
    'http://feed1',
    'http://feed2',
    'http://feed3'
  ];
?>

#index.php
<?php
  echo SimplePieWP(include('feed_array.php'),[
    'items' => 5
  ]);
?>

But keep in mind that if the include fails, it throws a warning and returns false instead.