Reputation: 95
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
Upvotes: 0
Views: 147
Reputation: 7911
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.
Upvotes: 1