3v4l.org

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