Generate random string

Uses alphanumeric symbols to generate string of specified length.

php
fork add to bundle source
function random_string($length = 8) { $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $result = ''; for ($i = 0; $i < $length; $i++) { $result .= $chars{mt_rand(0, strlen($chars) - 1)}; } return $result; }

usage

load_function('random_string'); echo random_string(); // ...
← how to use this in app?
create log ...inout