PHP: Random Salt String Generator

As i develop new CakePHP projects i like to spin the wheel with generating a “secure” salt string to be used in core.php. Instead of just bashing my head against the keyboard hoping for some random, usable, 40 character long string, i decided to let php do it for me, which i run from console!

<?php
function generateCode($length=8){
$string = "";
$possible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 
for($i=0;$i < $length;$i++) {
$char = $possible[mt_rand(0, strlen($possible)-1)];
$string .= $char;
}
 
return $string;
}
 
for($i=0; $i < 100; $i++){
echo generateCode(40)."\n";
}
?>