3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = <<<STR THEDLSDARNVNS CCVBXXMTGFRWS CVIYTVBVSDOPTR VBNMAITYSURFD MOTYYERSAWERTY MOITRUHDYRTBDI VNOWUNMBORN STR; $fib = [1,2,3,5,8,13]; foreach (explode(PHP_EOL, $str) as $line) { // hack to make the array 1-based var_dump($line); $arr = str_split($line); array_unshift($arr, 'foo'); unset($arr[0]); $arr = array_filter($arr); foreach ($arr as $pos => $c) { // start at if ($pos > 9) { $index = $pos % 9; } else { $index = $pos; } // if in $fib array if (in_array($index, $fib)) { echo $c; } } }
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(14) "THEDLSDARNVNS " THELANVN string(14) "CCVBXXMTGFRWS " CCVXTFRW string(15) "CVIYTVBVSDOPTR " CVITVDOPRstring(14) "VBNMAITYSURFD " VBNAYURF string(15) "MOTYYERSAWERTY " MOTYSWERYstring(15) "MOITRUHDYRTBDI " MOIRDRTBIstring(11) "VNOWUNMBORN" VNOUBRN
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/EAaFU on line 13
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/EAaFU on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/EAaFU on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/EAaFU on line 13
Process exited with code 255.