• PHP Video Tutorials

PHP - Stats Rand Phrase To Seeds() Function



Definition and Usage

The stats_rand_phrase_to_seeds() function can generate two seeds for the RGN random number generator. This function uses a phrase (characted string) to generate two seeds for the RGN random number generator. Trailing blanks are eliminated before the seeds are generated. Generated seed values will fall in the range 1..2^30.

Syntax

  array stats_rand_phrase_to_seeds( string $phrase )

Parameters

Sr.No Parameter Description
1

phrase

The input phrase

Return Values

The stats_rand_phrase_to_seeds() function can returns an array of two integers.

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 generate two seeds for the RGN random number generator by passing a phrase (characted string).

<?php
   $retval = stats_rand_phrase_to_seeds('pecl_math_stats');
   var_dump($retval);
?>

Output

This will produce following result −

array(2) { [0]=> int(778713008) [1]=> int(699140725) }
Advertisements