php - range function does not see $i -


i trying learn range , xrange functionality plugging php.net code code generator. when run following code given error:

unexpected '$i' (t_variable) on line 4

here code:

function xrange($start, $limit, $step) {     if ($start < $limit) {         ($i = $start; $i <= $limit; $i += $step) {             yield $i;         }     } else {         ($i = $start; $i >= $limit; $i -= $step) {             yield $i;         }     } }   foreach (range(1, 9, 2) $number) {     echo "$number "; } 

thanks in advnace insight!

from generators doc:

(php 5 >= 5.5.0)

so won't work php 5.4 or below.

if want try php 5.5 online, use codepad.viper-7.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -