What a pain. After a few hours of trying to figure out why some of my a list boxes were not working properly....the answer, php 4.3In PHP versions 4.1.0 through 4.3.2, range() sees numeric strings as strings and not integers. Instead, they will be used for character sequences. For example, "4242" is treated as "4".
[GRIPE] range()
Moderator: General Moderators
[GRIPE] range()
Wow, how did I miss this in the frigen manual range()

- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
For anyone who cares here is a function that I tested in PHP 4.3 and PHP 5 
Code: Select all
/* ACCEPT TWO VALUES LOW AND HIGH
RETURN AN ARRAY WITH THE RANGE OF VALUES LOW TO HIGH
*/
function getArrayFromRange($low_range,$high_range){
if($low_range > $high_range){
#REVERSE ARRAY
$new_array = range((int)$high_range,(int)$low_range);
$new_array = array_reverse($new_array);
}else{
$new_array = range((int)$low_range,(int)$high_range);
}
return $new_array;
}