Voting

: min(three, six)?
(Example: nine)

The Note You're Voting On

derek at php dot net
20 years ago
This should emulate range() a little better.
<?php
function range_wroar($low, $high, $step = 1) {
$arr = array();
$step = (abs($step)>0)?abs($step):1;
$sign = ($low<=$high)?1:-1;
if(
is_numeric($low) && is_numeric($high)) {
//numeric sequence
for ($i = (float)$low; $i*$sign <= $high*$sign; $i += $step*$sign)
$arr[] = $i;
} else {
//character sequence
if (is_numeric($low))
return
$this->range($low, 0, $step);
if (
is_numeric($high))
return
$this->range(0, $high, $step);
$low = ord($low);
$high = ord($high);
for (
$i = $low; $i*$sign <= $high*$sign; $i += $step*$sign) {

$arr[] = chr($i);
}
}
return
$arr;
}
?>

<< Back to user notes page

To Top