note 40923 added to function.rand

From: Date: Fri, 19 Mar 2004 05:57:46 +0000
Subject: note 40923 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-67048@lists.php.net to get a copy of this message
Heres how to create random yet web-safe colors in hex using rand(). $Color = '#'.substr(md5(rand()),0,6); I'll explain from the insdie out. rand() = creates a random number. md5 = Turns that random number in to a 32 bit long hex number. substr(,0,6) = takes the 1st 6 hex chars from the MD5 string. ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40923 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40923&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40923&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67048) next »