- var_dump: documentation ( source)
- array_unshift: documentation ( source)
- explode: documentation ( source)
- array_filter: documentation ( source)
- in_array: documentation ( source)
- str_split: documentation ( source)
<?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;
}
}
}