Answer the question
In order to leave comments, you need to log in
How to fix JSON error?
The task is simple - to parse the podcast feed. Here is the code:
<?php
$response = array("error" => FALSE);
$response["feed"] = array();
$url = "https://mayk.podfm.ru/rss";
$xml = simplexml_load_file($url);
for($i = 0; $i < 20; $i++){
$title = $xml->channel->item[$i]->title;
$pubDate = $xml->channel->item[$i]->pubDate;
$enclosure = $xml->channel->item[$i]->enclosure['url'];
$url = rtrim($enclosure, "?channel=rss");
$product = array();
$product["pod"]["title"] = $title;
$product["pod"]["date"] = $pubDate;
$product["pod"]["song"] = $url;
array_push($response["feed"], $product);
}
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question