Location: PHPKode > scripts > Generate random float numbers > generate-random-float-numbers/generate_random_float_numbers_class.php
<?php
class generate_random_float_numbers
{
	public $generated_numbers = array();

	function __construct($total, $how_many)
	{
		$i = 0;
		while ($i != $how_many) {
			if ($i == $how_many - 1) { $this->generated_numbers[count($this->generated_numbers)] = $total; } else {
				$this->generated_numbers[count($this->generated_numbers)] = round(lcg_value() * intval($total / rand(1, rand(2, $how_many - $i))), 2);
				$total -= $this->generated_numbers[count($this->generated_numbers) - 1];
			}
			$i++;
		}
	}
}
?>
Return current item: Generate random float numbers