Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<? $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"; echo "Ссылка: " . $item['link'] . "\n\n"; break; } } } } }
Copy Clear