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
<?php
include ("config.php");
$xmlstring = file_get_contents(POSTIMEES_URL);
$xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
$x= 1;
foreach ($array['channel']['item'] as $key => $value){
getCategory($value);
echo $x." ".$value["title"]."<br>";
$x++;
}
function getCategory($data)
{
if(!isset($data['category'])){
return;
}
$category = is_array($data['category']) ? $data['category'] : [$data['category']];
foreach($category as $c){
echo $c;
if($c !==end($category)){
echo "=>";
}
}
echo "<br>";
}
$array1 = $array2 = array("category", "category", "category", "category");
natsort($array2);
echo "\nСортировка natural order\n";
print_r($array2);