/ Published in: PHP
This function generates random value from given parameters (length and characters).
Expand |
Embed | Plain Text
function random_value( $length = 6, $characters = array( 'a', 'b', 'c' ) ) { // Parameters are optional. $data = ''; // Define empty string for later (return $data). for( $i = 0; $i < $length; $i++ ) { // Loop will execute the same times as value of variable $lenght. $data .= $characters[ mt_rand( 0, $from_zero ) ]; // Adds one random symbol from array $characters each time loop executes. } return $data; } // By daGrevis. ##
You need to login to post a comment.
