• PHP Video Tutorials

PHP - Stats Rand Setall() Function



Definition and Usage

The stats_rand_setall() function can set seed values to the random generator.

Syntax

  void stats_rand_setall( int $iseed1, int $iseed2 )

Parameters

Sr.No Parameter Description
1

iseed1

The value which is used as the random seed. First of two integer seeds

2

iseed2

The value which is used as the random seed. Second of two integer seeds

Return Values

The stats_rand_setall() function can set iseed1 and iseed2 as seed values to the random generator used in statistic functions.

The stats_rand_setall() function doesn't return any value.

Dependencies

This function was first introduced in statistics extension (PHP 4.0.0 and PEAR 1.4.0). We have used latest release of stats-2.0.3 (PHP 7.0.0 or newer and PEAR 1.4.0 or newer) for this tutorial

Example

In the following example, we set 10 and 20 as seed values to the random generator used in statistic functions.

<?php
   stats_rand_setall(10, 20);
   $sd = stats_rand_getsd();
   echo $sd[0], "\n";
   echo $sd[1], "\n";
?>

Output

This will produce following result −

10
20
Advertisements