PHP random string generator

PHP random number function, PHP generate random number and strings

PHP Random String Function

<?php
function random_string($length = 10) {
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';
    $chars_length = strlen($chars);
    $string = '';
    for ($i = 0; $i < $length; $i++) {
        $string .= $chars[rand(0, $chars_length - 1)];
    }
    return $string;
}

//usage
echo random_string(15); //d8iSfUi8484_rij

?>

PHP Random Number Function

<?php
function random_number($length = 10) {
    $numbers = '0123456789';
    $numbers_length = strlen($numbers);
    $number = '';
    for ($i = 0; $i < $length; $i++) {
        $number .= $numbers[rand(0, $numbers_length - 1)];
    }
    return $number;
}

//usage
echo random_number(15); //659854320686554
?>