3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $rss = new DOMDocument(); $rss->load('http://static.cricinfo.com/rss/livescores.xml'); $list = array(); $found = 0; foreach ($rss->getElementsByTagName('item') as $node) { $item = array( 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue ); array_push($list, $item); } $numberofresults = 20; for ($i = 0; $i < $numberofresults; $i++) { $title = $list[$i]['title']; $titletolower = strtolower($title); $desc = $list[$i]['desc']; $desctolower = strtolower($desc); if (strpos($desctolower, "*") !== false) { $desc = 'Live'; } else { $desc = ' Not Live'; } echo $title . "\n"; echo $desc . "\n"; $found++; } if ($found == 0) { echo $list[$i]['title'][0]; } ?>
based on BaljB
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
Warning: DOMDocument::load(): php_network_getaddresses: getaddrinfo failed: System error in /in/9XS2S on line 3 Warning: DOMDocument::load(http://static.cricinfo.com/rss/livescores.xml): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/9XS2S on line 3 Warning: DOMDocument::load(): I/O warning : failed to load external entity "http://static.cricinfo.com/rss/livescores.xml" in /in/9XS2S on line 3 Notice: Undefined offset: 0 in /in/9XS2S on line 18 Notice: Undefined offset: 0 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 1 in /in/9XS2S on line 18 Notice: Undefined offset: 1 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 2 in /in/9XS2S on line 18 Notice: Undefined offset: 2 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 3 in /in/9XS2S on line 18 Notice: Undefined offset: 3 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 4 in /in/9XS2S on line 18 Notice: Undefined offset: 4 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 5 in /in/9XS2S on line 18 Notice: Undefined offset: 5 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 6 in /in/9XS2S on line 18 Notice: Undefined offset: 6 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 7 in /in/9XS2S on line 18 Notice: Undefined offset: 7 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 8 in /in/9XS2S on line 18 Notice: Undefined offset: 8 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 9 in /in/9XS2S on line 18 Notice: Undefined offset: 9 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 10 in /in/9XS2S on line 18 Notice: Undefined offset: 10 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 11 in /in/9XS2S on line 18 Notice: Undefined offset: 11 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 12 in /in/9XS2S on line 18 Notice: Undefined offset: 12 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 13 in /in/9XS2S on line 18 Notice: Undefined offset: 13 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 14 in /in/9XS2S on line 18 Notice: Undefined offset: 14 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 15 in /in/9XS2S on line 18 Notice: Undefined offset: 15 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 16 in /in/9XS2S on line 18 Notice: Undefined offset: 16 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 17 in /in/9XS2S on line 18 Notice: Undefined offset: 17 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 18 in /in/9XS2S on line 18 Notice: Undefined offset: 18 in /in/9XS2S on line 21 Not Live Notice: Undefined offset: 19 in /in/9XS2S on line 18 Notice: Undefined offset: 19 in /in/9XS2S on line 21 Not Live
Output for hhvm-3.22.0
Warning: Failed to open http://static.cricinfo.com/rss/livescores.xml (Could not resolve host: static.cricinfo.com) in /in/9XS2S on line -1 Notice: Undefined index: 0 in /in/9XS2S on line -1 Notice: Undefined index: 0 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 1 in /in/9XS2S on line -1 Notice: Undefined index: 1 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 2 in /in/9XS2S on line -1 Notice: Undefined index: 2 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 3 in /in/9XS2S on line -1 Notice: Undefined index: 3 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 4 in /in/9XS2S on line -1 Notice: Undefined index: 4 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 5 in /in/9XS2S on line -1 Notice: Undefined index: 5 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 6 in /in/9XS2S on line -1 Notice: Undefined index: 6 in /in/9XS2S on line -1 Not Live Notice: Undefined index: 7 in /in/9XS2S on line -1 Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live
Output for hhvm-3.21.3
Warning: Failed to open http://static.cricinfo.com/rss/livescores.xml (Could not resolve host: static.cricinfo.com) in /in/9XS2S on line 3 Notice: Undefined index: 0 in /in/9XS2S on line 18 Notice: Undefined index: 0 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 1 in /in/9XS2S on line 18 Notice: Undefined index: 1 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 2 in /in/9XS2S on line 18 Notice: Undefined index: 2 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 3 in /in/9XS2S on line 18 Notice: Undefined index: 3 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 4 in /in/9XS2S on line 18 Notice: Undefined index: 4 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 5 in /in/9XS2S on line 18 Notice: Undefined index: 5 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 6 in /in/9XS2S on line 18 Notice: Undefined index: 6 in /in/9XS2S on line 21 Not Live Notice: Undefined index: 7 in /in/9XS2S on line 18 Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live Not Live
Output for hhvm-3.18.5
Warning: Failed to open http://static.cricinfo.com/rss/livescores.xml (Could not resolve host: static.cricinfo.com) Notice: Undefined index: 0 in /in/9XS2S on line 18 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 19 Notice: Undefined index: 0 in /in/9XS2S on line 21 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 22 Warning: strpos() expects parameter 1 to be string, null given in /in/9XS2S on line 24 Live Notice: Undefined index: 1 in /in/9XS2S on line 18 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 19 Notice: Undefined index: 1 in /in/9XS2S on line 21 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 22 Warning: strpos() expects parameter 1 to be string, null given in /in/9XS2S on line 24 Live Notice: Undefined index: 2 in /in/9XS2S on line 18 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 19 Notice: Undefined index: 2 in /in/9XS2S on line 21 Warning: strtolower() expects parameter 1 to be string, null given in /in/9XS2S on line 22 Warning: strpos() expects parameter 1 to be string, null given in /in/9XS2S on line 24 Live Live Live Live Live Live Live Live Live Live Live Live Live Live Live Live Live Live