Try the following. I simply use the PID as an initial random number generator, then grab part of it and compare it to the min and max values.
<?php
// Set your min and max values here
$min = 1;
$max = 5;
// Get the process ID number
$random = getmypid();
// Grab part of the ID number. I start at the second
// character since the first character is often '1'. I also
// grab enough characters (i.e. if my max number is a
// double digit number, I grab 2 characters from the
// $random string.
$first = substr($random,1,strlen($max));
// If the number I grab is larger than the 'max' value,
// I simply subtract the max value from it. If the number
// I grab is smaller than the min value, I add the 'max'
// value.
if ($first > $max) {
$first = $first - $max;
} elseif ($first < $min) {
$first = $first + $max;
}
//Now remove leading zeros.
$first = ltrim($first, '0');
echo "Random Number is $first";
?>