
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 1.20 KB | hits: 12 | expires: Never
array_rand() array to string?
$hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
$random_color = array_rand($hex,6);
echo implode($random_color);
echo $hex[$random_color[0]];
echo $hex[$random_color[1]];
echo $hex[$random_color[2]];
echo $hex[$random_color[3]];
echo $hex[$random_color[4]];
echo $hex[$random_color[5]];
$hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
shuffle($hex);
echo sub_str(implode('',$hex),0,6);
printf('%02x%02x%02x',mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
printf('%06x',mt_rand(0,16777215));
implode('', array_rand(array_flip($hex), 6));
dechex(mt_rand(0, 0xFFFFFF));
$random_color = array_rand(array_flip($hex), 6);
<?php
$hex = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
shuffle($hex);
echo implode(array_slice($hex, 0, 6));
substr(md5(time()),-6);
substr(md5(uniqid()),-6);
$result = "";
$random_color = array_rand($hex, 6);
foreach ($random_color as $randomIndex) {
$result = $result . $hex[$randomIndex];
}
$color = '';
while(strlen($c) < 6) {
$color .= sprintf("%02X", mt_rand(0, 255));
}
mt_srand((double)microtime()*1000000);