note 42441 deleted from function.range by tomsommer

From: Date: Mon, 17 May 2004 06:32:46 +0000
Subject: note 42441 deleted from function.range by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69695@lists.php.net to get a copy of this message
Note Submitter: Forrester@tfcustomized.com ---- A mistake in my previous post...I accidently used native C syntax. Fixed: 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; } // usage: myRange(low,high, ... [optional step]); // example: print_r(myRange(1,11,2)); // output: // Array ( // [0] => 1 // [1] => 3 // [2] => 5 // [3] => 7 // [4] => 9 // [5] => 11 // ) Sorry about that :)

« previous php.notes (#69695) next »