note 42467 added to function.range
| From: | Forrester at tfcustomized dot com | Date: | Mon, 17 May 2004 23:57:16 +0000 |
| Subject: | note 42467 added to function.range | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69745@lists.php.net to get a copy of this message | ||
Since users of < PHP 5.0.0 don't have the option of the step parameter, I've created a
little function to account for it:
@USAGE: (int low, int high [, int step])
function myRange($low,$high,$step=1)
{
$ranArray = range($low,$high);
$step--;
$keys = count($ranArray);
for($i=0;$i<$keys;$i++)
{
$retArray[] = $ranArray[$i];
$i = $i + $step;
}
return $retArray;
}
// Example usage:
print_r(myRange(1,11,2));
// Returns the array:
// [0] => 1
// [1] => 3
// [2] => 5
// [3] => 7
// [4] => 9
// [5] => 11
----
Manual Page -- http://www.php.net/manual/en/function.range.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42467
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42467&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42467&report=yes
Search -- http://master.php.net/manage/user-notes.php