Hello this is the cod I am using but as the author said it runs on PHP 5.3
I am using 5.2.17 I guess this is why I have this error Parse error: syntax error, unexpected T_FUNCTION on line 14 (usort($entries, function ($x, $y) {)
What can I do about it ?
$feeds = array(
'http://www.example.org/feed1.rss',
'http://www.example.org/feed2.rss'
);
// Get all feed entries
$entries = array();
foreach ($feeds as $feed) {
$xml = simplexml_load_file($feed);
$entries = array_merge($entries, $xml->xpath('/rss//item'));
}
// Sort feed entries by pubDate (ascending)
usort($entries, function ($x, $y) {
return strtotime($x->pubDate) - strtotime($y->pubDate);
});
print_r($entries);
It’s because that code is using a lamba function.
To accomplish this in pre 5.3, you could simply define the function and pass the function name as the argument, i.e.,
or create the function using create_function()