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
<?php //создаем из xml один огромный массив $url="https://www.err.ee/rss"; $data=file_get_contents($url); $xml=simplexml_load_string($data); $json=json_encode($xml); $array=json_decode($json,true); $data=$array['channel']; //выводит функцию //print_r(getPubDate($data['item'])); print_r($array); //ВСЕ ФУНКЦИИ : //функция category function getCategory($array){ $category=[]; foreach($array as $k=>$v){ if(is_array($v['category'])){ $category[]=end($v['category']); } } return array_count_values($category); } //функция author function getAuthor($array){ $author=[]; foreach($array as $k=>$v){ if(is_array($v['author'])){ foreach($v['author'] as $k=>$a){ $author[]=$a; } }else{ $author[]=$v['author']; } } return array_count_values($author); } //функция date function getPubDate($array){ $date=[]; foreach($array as $k=>$v){ if(is_array($v['pubDate'])){ foreach($v['pubDate'] as $k=>$a){ $date[]=$a; } }else{ $date[]=$v['pubDate']; } } return array_count_values($date); }
Copy Clear