Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?
$url = "https://rus.postimees.ee/rss";
$xmlstring = file_get_contents($url);
$xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json, TRUE);
if (isset($array['channel']['item'])) {
foreach ($array['channel']['item'] as $item) {
if (isset($item['category'])) {
$categories = is_array($item['category']) ? $item['category'] : [$item['category']];
foreach ($categories as $category) {
if (stripos($category, 'Эстония') !== false) {
echo "Заголовок: " . $item['title'] . "\n";
break;
}
}
}
}
}