3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $scandir = scandir('c:/keycounter'); $stats = array(); foreach($scandir as $filename){ if(substr($filename, -4) !== '.day') continue; $date = substr($filename, 0, -4); $stats[$date]= array('k' => 0, 'm' => 0); $content = file_get_contents('c:/keycounter/'.$filename); $lines = explode("\n", $content); foreach($lines as $line){ if($line === '') { continue; } $exp2 = explode(",", $line); $stats[$date]['k']+=intval($exp2[0]); $stats[$date]['m']+=intval($exp2[1]); } }
Output for 5.2.3 - 7.1.0
Warning: scandir(c:/keycounter): failed to open dir: No such file or directory in /in/Dcs5Q on line 2 Warning: scandir(): (errno 2): No such file or directory in /in/Dcs5Q on line 2 Warning: Invalid argument supplied for foreach() in /in/Dcs5Q on line 5
Output for 5.0.0 - 5.2.2
<br /> <b>Warning</b>: scandir(c:/keycounter) [<a href='function.scandir'>function.scandir</a>]: failed to open dir: No such file or directory in <b>/in/Dcs5Q</b> on line <b>2</b><br /> <br /> <b>Warning</b>: scandir() [<a href='function.scandir'>function.scandir</a>]: (errno 2): No such file or directory in <b>/in/Dcs5Q</b> on line <b>2</b><br /> <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/in/Dcs5Q</b> on line <b>5</b><br />
Output for 4.4.5 - 4.4.9
<br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/Dcs5Q</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.4
<br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/Dcs5Q</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Call to undefined function: scandir() in <b>/in/Dcs5Q</b> on line <b>2</b><br />