random_number

Generates a random number with a few parameters to customise your results

Example

[%random_number length:'5'/%]

Min and Max

When both min and max are defined, the function will return a random number between the two, excluding max value. For example, if min equals 4 and max equals 10, then it will generate number will be between 4 and 9:

[%random_number min:'4' max:'10'/%]

When either one of min or max are not defined they will be ignored completely. Instead, fix will be used (If length is provided it will be used as well, however this is not required).

Duplicate results

Using the id:'' param, you can generate the same number in multiple places in the template. Use the id:'' value the same both times. For example:

[%random_number length:'10' id:'1' /%]<br />
[%random_number length:'10' id:'1' /%]<br />

Returns:

4773699986
4773699986

Timestamp

The timestamp:'' prepends the unix timestamp to the number:

[%random_number length:'10' timestamp:'1' /%]

Returns:

524215158118625701030179917

In this example 52421515811862570 is the current unix timestamp and 1030179917 is the random number.

Parameters

Name Options Description
length:'' Integer This is a required param to set the length of the number generated
timestamp:'' 1/0 Can be used instead of the length param or along side it. Generates a number with the time stamp.
id:'' Integer Used to duplicate results on the page, if you have two random_number tags with the same ID, the resulting random number string will be the same on both.
min:'' Integer The shortest length the resulting number can be. Can not be used with the length param
max:'' Integer The longest length the resulting number can be. Can not be used with the length param
fix:'' 1 / 0 When true it will force the length of the result to be exactly the length param. Can not be used with the min/max params

Was this article useful?

Be notified when this page is updated. Optional.