<?php
// your code goes here
function xrange($start,$end,$reset=false) {
static $position = NULL;
if($position == NULL || $reset) {
$position = 0;
}
$value = $position+$start;
if($value <= $end) {
return array($position++, $value); } else {
}
}
while(list($key, $value) = xrange
(1,10)) { echo "$key => $value\n";
}
PD9waHAKCi8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCmZ1bmN0aW9uIHhyYW5nZSgkc3RhcnQsJGVuZCwkcmVzZXQ9ZmFsc2UpIHsKCXN0YXRpYyAkcG9zaXRpb24gPSBOVUxMOwoJCglpZigkcG9zaXRpb24gPT0gTlVMTCB8fCAkcmVzZXQpIHsKCQkkcG9zaXRpb24gPSAwOwoJfQoJCgkkdmFsdWUgPSAkcG9zaXRpb24rJHN0YXJ0OwoJCglpZigkdmFsdWUgPD0gJGVuZCkgewoJCXJldHVybiBhcnJheSgkcG9zaXRpb24rKywgJHZhbHVlKTsKCX0gZWxzZSB7CgkJcmV0dXJuIGFycmF5KCk7Cgl9Cn0KCndoaWxlKGxpc3QoJGtleSwgJHZhbHVlKSA9IHhyYW5nZSgxLDEwKSkgewoJZWNobyAiJGtleSA9PiAkdmFsdWVcbiI7Cn0K