php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15920 range() with a step parameter
Submitted: 2002-03-06 20:54 UTC Modified: 2003-02-08 12:56 UTC
From: pgerzson at freestart dot hu Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.2 OS: Any
Private report: No CVE-ID: None
 [2002-03-06 20:54 UTC] pgerzson at freestart dot hu
I think it would be useful in some situation if the range() function can take a third optional parameter (called "step" or whatever you want) which specifies the space between two consecutive elements in the resulting array. For example:

$array = range(1, 5, 2); // array(1,3,5);

It might be always positive to understand its effect easily.

$array = range('Z', 'A', 3); // array('Z', 'W', 'T', 'Q', ...);

If the second boundary cannot be included regarding to the step parameter, just simply leave it out:

$array = range(1, 6, 2); // array(1,3,5);


That's all.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-08 12:55 UTC] moriyoshi@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 [2003-02-08 12:56 UTC] moriyoshi@php.net
No, sorry, this request is realised in CVS versions you can fetch at http://snaps.php.net/


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 08 18:00:01 2025 UTC