3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = file_get_contents('http://gamesurf.tiscali.it/dynamic/articolo/CHIAVE/fina1294224760111/TIPO_PAGINA/recensione'); $dom = new DOMDocument(); @$dom->loadHTML($data); $span = $dom->getElementsByTagName('span'); $paragraph = $dom->getElementsByTagName('p'); $startList = '<ol type="1">'; $endList = '</ol>'; $tBox = array(); $pBox = array(); foreach ($span as $s) { if ($s->hasAttribute('class') && $s->getAttribute('class') == 'boxtitle2') { array_push($tBox,$dom->saveHTML($s)); } } foreach ($paragraph as $p) { if ($p->hasAttribute('class') && $p->getAttribute('class') == 'boxp') { array_push($pBox,html_entity_decode($dom->saveHTML($p))); } } if (!empty($tBox) && !empty($pBox)) { foreach ($tBox as $k => $v) { $commento = $commento.'<li>'.$v.' - '.htmlentities($pBox[$k]).'</li>'; } $commento = $startList.$commento.$endList; } echo $commento; ?>

preferences:
41.83 ms | 402 KiB | 5 Q