3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $days = []; $searchData = ['dat' => '2015-11-10']; $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 0R16t
Output for 5.4.9 - 5.4.45, 5.6.28, 7.0.20 - 7.2.0
Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 )
Output for 7.0.6
Array ( [0] => -175 [1] => -174 [2] => -173 [3] => -172 [4] => -171 [5] => -170 [6] => -169 )
Output for 7.0.5
Array ( [0] => -145 [1] => -144 [2] => -143 [3] => -142 [4] => -141 [5] => -140 [6] => -139 )
Output for 7.0.4
Array ( [0] => -121 [1] => -120 [2] => -119 [3] => -118 [4] => -117 [5] => -116 [6] => -115 )
Output for 7.0.3
Array ( [0] => -129 [1] => -128 [2] => -127 [3] => -126 [4] => -125 [5] => -124 [6] => -123 )
Output for 7.0.2
Array ( [0] => -134 [1] => -133 [2] => -132 [3] => -131 [4] => -130 [5] => -129 [6] => -128 )
Output for 7.0.1
Array ( [0] => -135 [1] => -134 [2] => -133 [3] => -132 [4] => -131 [5] => -130 [6] => -129 )
Output for 7.0.0
Array ( [0] => -138 [1] => -137 [2] => -136 [3] => -135 [4] => -134 [5] => -133 [6] => -132 )
Output for 5.6.21
Array ( [0] => -174 [1] => -173 [2] => -172 [3] => -171 [4] => -170 [5] => -169 [6] => -168 )
Output for 5.6.20
Array ( [0] => -152 [1] => -151 [2] => -150 [3] => -149 [4] => -148 [5] => -147 [6] => -146 )
Output for 5.6.19
Array ( [0] => -119 [1] => -118 [2] => -117 [3] => -116 [4] => -115 [5] => -114 [6] => -113 )
Output for 5.6.18
Array ( [0] => -126 [1] => -125 [2] => -124 [3] => -123 [4] => -122 [5] => -121 [6] => -120 )
Output for 5.6.17
Array ( [0] => -130 [1] => -129 [2] => -128 [3] => -127 [4] => -126 [5] => -125 [6] => -124 )
Output for 5.6.16
Array ( [0] => -139 [1] => -138 [2] => -137 [3] => -136 [4] => -135 [5] => -134 [6] => -133 )
Output for 5.6.15
Array ( [0] => -140 [1] => -139 [2] => -138 [3] => -137 [4] => -136 [5] => -135 [6] => -134 )
Output for 5.6.14
Array ( [0] => -144 [1] => -143 [2] => -142 [3] => -141 [4] => -140 [5] => -139 [6] => -138 )
Output for 5.6.13
Array ( [0] => -157 [1] => -156 [2] => -155 [3] => -154 [4] => -153 [5] => -152 [6] => -151 )
Output for 5.6.12
Array ( [0] => -162 [1] => -161 [2] => -160 [3] => -159 [4] => -158 [5] => -157 [6] => -156 )
Output for 5.6.11
Array ( [0] => -166 [1] => -165 [2] => -164 [3] => -163 [4] => -162 [5] => -161 [6] => -160 )
Output for 5.6.10
Array ( [0] => -167 [1] => -166 [2] => -165 [3] => -164 [4] => -163 [5] => -162 [6] => -161 )
Output for 5.6.9
Array ( [0] => -169 [1] => -168 [2] => -167 [3] => -166 [4] => -165 [5] => -164 [6] => -163 )
Output for 5.6.8
Array ( [0] => -172 [1] => -171 [2] => -170 [3] => -169 [4] => -168 [5] => -167 [6] => -166 )
Output for 5.5.35
Array ( [0] => -194 [1] => -193 [2] => -192 [3] => -191 [4] => -190 [5] => -189 [6] => -188 )
Output for 5.5.34
Array ( [0] => -153 [1] => -152 [2] => -151 [3] => -150 [4] => -149 [5] => -148 [6] => -147 )
Output for 5.5.33
Array ( [0] => -120 [1] => -119 [2] => -118 [3] => -117 [4] => -116 [5] => -115 [6] => -114 )
Output for 5.5.32
Array ( [0] => -128 [1] => -127 [2] => -126 [3] => -125 [4] => -124 [5] => -123 [6] => -122 )
Output for 5.5.31
Array ( [0] => -132 [1] => -131 [2] => -130 [3] => -129 [4] => -128 [5] => -127 [6] => -126 )
Output for 5.5.30
Array ( [0] => -143 [1] => -142 [2] => -141 [3] => -140 [4] => -139 [5] => -138 [6] => -137 )
Output for 5.5.29
Array ( [0] => -159 [1] => -158 [2] => -157 [3] => -156 [4] => -155 [5] => -154 [6] => -153 )
Output for 5.5.28
Array ( [0] => -163 [1] => -162 [2] => -161 [3] => -160 [4] => -159 [5] => -158 [6] => -157 )
Output for 5.5.27
Array ( [0] => -164 [1] => -163 [2] => -162 [3] => -161 [4] => -160 [5] => -159 [6] => -158 )
Output for 5.5.26
Array ( [0] => -168 [1] => -167 [2] => -166 [3] => -165 [4] => -164 [5] => -163 [6] => -162 )
Output for 5.5.25
Array ( [0] => -171 [1] => -170 [2] => -169 [3] => -168 [4] => -167 [5] => -166 [6] => -165 )
Output for 5.5.24
Array ( [0] => -196 [1] => -195 [2] => -194 [3] => -193 [4] => -192 [5] => -191 [6] => -190 )
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/pjmkV on line 3
Process exited with code 255.