<?php
$city = “stoleco” ; sceglie la citt√† $contents = file_get_contents(“http:”.$city.“.myminicity.com/xml”); prende il contenuto dello xml legge i valori:
$valori = eregi(“<city>(.*)</city>”, $contents, $array); $city = explode(“<city>”, $array[0]);
ereg(“<ranking>(.*)</ranking>”, $city[1], $ranking); ereg(“<population>(.*)</population>”, $city[1], $population); ereg(“<incomes>(.*)</incomes>”, $city[1], $incomes); ereg(“<unemployment>(.*)</unemployment>”, $city[1], $unemployment); ereg(“<transport>(.*)</transport>”, $city[1], $transport); ereg(“<criminality>(.*)</criminality>”, $city[1], $criminality); ereg(“<pollution>(.*)</pollution>”, $city[1], $pollution); ereg(“<nextnuke>(.*)</nextnuke>”, $city[1], $nextnuke); ereg(“<signatures>(.*)</signatures>”, $city[1], $signatures);
confronta i valori e trova il massimo: $full = 100 ; $nottransport = $full - $transport[1] ; $numeri = array('ind' ⇒ $unemployment[1], 'tra' ⇒ $nottransport, 'sec' ⇒ $criminality[1], 'env' ⇒ $pollution[1]); $numeric = $numeri; arsort($numeri); rsort($numeric); $category = array_search($numeric[0], $numeri); $categoryname = $category; if ($numeric[0] == 0) { $category = “”; $categoryname = “popolazione”; }; switch ($category) { case 'ind': $categoryname = 'industrie'; $img = 'http://data.myminicity.com/img/icons/newind.gif'; break; case 'tra': $categoryname = 'trasporti'; $img = 'http://data.myminicity.com/img/icons/tra.gif'; break; case 'sec': $categoryname = 'sicurezza'; $img = 'http://data.myminicity.com/img/icons/sec.gif'; break; case 'env': $categoryname = 'parchi'; $img = 'http://data.myminicity.com/img/icons/env.gif'; break; case 'com': $categoryname = 'commercio'; $img = 'http://data.myminicity.com/img/icons/com.gif'; break; default: $categoryname = 'popolazione'; $img = 'http://data.myminicity.com/img/icons/birth.gif'; } thanks to Jollyno and http://net-lord.net/scripts/minicity.phps by Begli echo “<ul>”; echo “<li>Ranking: ”.$ranking[1].“</li>” ; echo “<li>Population: ”.$population[1].“</li>” ; echo “<li> unemployment: ”.$unemployment[1].“</li>” ; echo “<li> transport: ”.$transport[1].“</li>” ; echo “<li> criminality: ”.$criminality[1].“</li>” ; echo “<li> pollution: ”.$pollution[1].“</li>” ; echo “<li>valore massimo: ”.$category.“ ”.$numeric[0]; echo “<li>Stoleco ha bisogno di ”.$categoryname.“: <a href=\”http://stoleco.myminicity.com/“.$category.”\“>http://stoleco.myminicity.com/”.$category.“</a></li>”; echo $numeric[0].“, ”.$numeric[1].“, ”.$numeric[2].“, ”.$numeric[3]; echo “</ul>”; ?>