I have this php which loads rss feed for Economic news. Is it possible to play a sound when the rss feed adds a new title? I have not tried anything yet because i have no idea how to do it. I suppose what i need to do is store the variable from title and then compare it and after that call a function on javascript to play the sound.
<?php
$rss = new DOMDocument();
$rss->load('https://rss.dailyfx.com/feeds/alerts/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 5;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$description = $feed[$x]['desc'];
$date = date('l F d, Y, H:m', strtotime($feed[$x]['date']));
echo '<p><strong><a " title="'.$title.'">'.$title.'</a></strong><br />';
echo '<small><em style="color:red; text-align:center;"> '.$date.'</em> </small></p>';
}
?>