générer un code couleur hexiste unique aléatoire à l'aide de PHP
echo '#' . substr(str_shuffle('ABCDEF0123456789'), 0, 6);
Ankur
echo '#' . substr(str_shuffle('ABCDEF0123456789'), 0, 6);
function random_part() {
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}
function randomHEX($amount) {
$_result = "";
for ($i = 0 ; $i < $amount; $i++) {
$_result .= random_part();
}
return $_result;
}
//to get a 16 HEX number
echo randomHEX(8);
function uploadAndCompress($compression=60) { //Default compression is 60%
$randomFileName = randomHex();
$tempgifFileName = $randomFileName.".gif";
$randomFileName = randomHex();
$tempgifFileName = $randomFileName.".gif";