Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for an alternative to the range() function 1

Status
Not open for further replies.

trantron

Programmer
Joined
Feb 12, 2004
Messages
15
Location
US
Looking for an alternative to the range() function

It is not working on an older version of PHP that I am stuck using.

According to the PHP manual:

Note: Prior to PHP version 4.1.0, range() only generated incrementing integer arrays. Support for character sequences and decrementing arrays was added in 4.1.0. Character sequence values are limited to a length of one. If a length greater than one is entered, only the first character is used.

If you know of a way of getting the same result as this function, I would really appreciate your help.
 
Just write it yourself. It's a simple loop construct.
Code:
function trantronRange($min,$max,$step=1){
  # loop
  for($i=intval($min);$i+intval($step);$i<=intval($max)){
      $tArray[] = $i;
  }
  return($tArray);
}

Better even, upgrade that obsolotete PHP or change your host.
 
Yes! Why couldn't I think of that!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top