3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tsId = 'X1C77CF6EE730D2E88A284D7203D1B20F'; $cacheFileName = '/tmp/'.$tsId.'.xml'; $cacheTimeOut = 43200; // half a day $apiUrl = 'http://www.trustedshops.com/api/ratings/v1/'.$tsId.'.xml'; $xmlFound = false; if ($xml = simplexml_load_file($apiUrl)) { $xPath = "/shop/ratings/result[@name='average']"; $result = (float) $xml -> xpath($xPath); $avg = $result[0]->asXml(); $max = "5.00"; $count = $xml->ratings["amount"]; $shopName = $xml->name; $xmlFound = true; } if ($xmlFound) { ?> <a href="http://www.trustedshops.eu/seller-rating/">Trusted Shops seller rating</a>:<span xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review-aggregate"> <span rel="v:rating"><span property="v:value"><?php echo $avg;?> </span> </span> / <span property="v:best"><?php echo $max;?> </span> of <span property="v:count"><?php echo $count;?> </span> <a href="https://www.trustedshops.de/bewertung/info_<?php echo $tsId?>.html" title="<?php echo $shopName;?> bewertungen"><?php echo $shopName;?> ratings</a> </span> <?php } function cachecheck($filename_cache, $timeout = 10800) { if (file_exists($filename_cache) && time() - filemtime($filename_cache) < $timeout) { return true; } return false; }

preferences:
26.82 ms | 402 KiB | 5 Q