note 99947 added to function.mt-rand

From: Date: Thu, 16 Sep 2010 11:25:03 +0000
Subject: note 99947 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-172631@lists.php.net to get a copy of this message
Random hexadecimal creator <?php // http://blog.kesdi.com function randhex($minbasamak,$maxbasamak) { $a=0; $b=0; $hexmin=""; $hexmax=""; while ($a<$minbasamak) { $hexmin=$hexmin."0"; $a++; } while ($b<$maxbasamak) { $hexmax=$hexmax."F"; $b++; } $min = hexdec($hexmin); // minimum hexadec converting $max = hexdec($hexmax); // maximum hexadec converting $random = mt_rand($min, $max); // create random value $random_hex = dechex($random); // converting hexadecimal if (strlen($random_hex) > $maxbasamak OR strlen($random_hex) < $minbasamak) randhex($minbasamak,$maxbasamak); // repate else return $random_hex; } // sample echo randhex(2,4); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 88.252.28.11 ---- Manual Page -- http://www.php.net/manual/en/function.mt-rand.php Edit -- https://master.php.net/note/edit/99947 Del: integrated -- https://master.php.net/note/delete/99947/integrated Del: useless -- https://master.php.net/note/delete/99947/useless Del: bad code -- https://master.php.net/note/delete/99947/bad+code Del: spam -- https://master.php.net/note/delete/99947/spam Del: non-english -- https://master.php.net/note/delete/99947/non-english Del: in docs -- https://master.php.net/note/delete/99947/in+docs Del: other reasons-- https://master.php.net/note/delete/99947 Reject -- https://master.php.net/note/reject/99947 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172631) next »