3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $days = []; $searchData = ['dat' => '2015-11-11']; $offset = 3; $now = date_create(); if (date_create($searchData['dat'])->modify('- '. $offset .' days') < $now) { $offsetStart = -1 * date_create($searchData['dat'])->diff($now)->format('%a'); } else { $offsetStart = -1 * $offset; } $offsetEnd = 2 * $offset + $offsetStart; for ($i = $offsetStart; $i <= $offsetEnd; $i++) { $days[] = $i; } print_r($days);
based on YrpJu
Output for 5.4.9 - 7.3.1
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 )
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0R16t on line 3
Process exited with code 255.