note 77633 added to function.uniqid
| From: | smp_info at yahoo dot com | Date: | Thu, 06 Sep 2007 12:38:40 +0000 |
| Subject: | note 77633 added to function.uniqid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130243@lists.php.net to get a copy of this message | ||
This function is painfully slow if you're using it to give images random names inside of a
loop. The following function will give you a random name *every* time and is much faster.
<?php
function nameImage($imgExtension)
{
return time() . substr(md5(microtime()), 0, rand(5, 12)) . $imgExtension;
}
?>
----
Server IP: 209.41.74.194
Probable Submitter: 65.185.136.246
----
Manual Page -- http://www.php.net/manual/en/function.uniqid.php
Edit -- https://master.php.net/note/edit/77633
Del: integrated -- https://master.php.net/note/delete/77633/integrated
Del: useless -- https://master.php.net/note/delete/77633/useless
Del: bad code -- https://master.php.net/note/delete/77633/bad+code
Del: spam -- https://master.php.net/note/delete/77633/spam
Del: non-english -- https://master.php.net/note/delete/77633/non-english
Del: in docs -- https://master.php.net/note/delete/77633/in+docs
Del: other reasons-- https://master.php.net/note/delete/77633
Reject -- https://master.php.net/note/reject/77633
Search -- https://master.php.net/manage/user-notes.php