note 106645 added to function.mt-rand

From: Date: Thu, 24 Nov 2011 12:43:22 +0000
Subject: note 106645 added to function.mt-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-184650@lists.php.net to get a copy of this message
To quickly build a human-readable random string for a captcha per example : <?php function random($length = 8) { $chars = 'bcdfghjklmnprstvwxzaeiou'; for ($p = 0; $p < $length; $p++) { $result .= ($p%2) ? $chars[mt_rand(19, 23)] : $chars[mt_rand(0, 18)]; } return $result; } ?> Note that I have removed q and y from $chars to avoid readability problems. ---- Server IP: 69.147.83.197 Probable Submitter: 82.236.182.157 ---- Manual Page -- http://www.php.net/manual/en/function.mt-rand.php Edit -- https://master.php.net/note/edit/106645 Del: integrated -- https://master.php.net/note/delete/106645/integrated Del: useless -- https://master.php.net/note/delete/106645/useless Del: bad code -- https://master.php.net/note/delete/106645/bad+code Del: spam -- https://master.php.net/note/delete/106645/spam Del: non-english -- https://master.php.net/note/delete/106645/non-english Del: in docs -- https://master.php.net/note/delete/106645/in+docs Del: other reasons-- https://master.php.net/note/delete/106645 Reject -- https://master.php.net/note/reject/106645 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184650) next »