Download the PHP package ierusalim/php-random-gen without Composer
On this page you can find all versions of the php package ierusalim/php-random-gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ierusalim/php-random-gen
More information about ierusalim/php-random-gen
Files in ierusalim/php-random-gen
Package php-random-gen
Short Description Random arrays, string, json-files generation
License Apache-2.0
Informations about the package php-random-gen
php-random-gen
Random Data Library
The library is easy to get up and running quickly. It is suitable for generating random bytes or strings from a given character set. It is possible to generate arrays of arbitrary depth of nesting as well as files with large data structures
Install
Via Composer
Usage
Generation random strings
This simple functions placed in file RandomStr.php and have have no dependencies
- genRandomStr($len)
- genRabdomBytes($bytes_cnt)
- setChars(list of values from which the result will be generate)
It is easy to understand from the examples below
Generation random Arrays
The random array generation class RandomArray are extended of RandomStr.
Simple examples:
The generation of random arrays occurs in memory, so with a large number of elements (100,000 or more) it may work slowly if using non-simple models.
But, when using simple numeric keys (1,2,3...n) and simple values range 0-65535, generation time of array 1 million elements (with depth of nested 2-3 levels) is less than 1 second.
See example:
What is Generation models?
Generation random keys and values can use 4 models:
- 0 Simple model - Is the fastest, 1,2,3..n for keys and 0-65535 for values.
- 1 Numeric range model - Use mt_rand(min,max) for random keys or values.
- 2 RandomStr model - Use function genRandomStr for gen. keys or values.
- 3 User function - Use user defined function for generation keys or values.
These models are set as follows:
-
0 Simple model
-
1 Numeric range model
-
2 RandomStr model (See description of the function genRandomStr)
- 4 User function model