Two Ways - Generate Five Digit Random Number in PHP for storing any file Uniquely
In this tutorial, We are showing five digit random number generation because it has multiple use into PHP programming. we can use it for renaming or adding some extra random digits after or before the image or file name. so that file or image name can become unique for storing value in database.First Method: -
$char = "BC0DEFG1HJK3LMO4PQRS5TUW6XYZa7bcdefg8hijklimno9pqrst";
$fivedigit = "";
for ($j = 0; $j < 5; $j++) { // We can Also make any number of code for storing file or image
$fivedigit .= $char[mt_rand(0, strlen($char)-1)];
}
echo $random_code = $fivedigit;
Second Method: -In this code, just have to add last variable after or before the file or image name.
$uniqueid_long=uniqid(rand(), true);
$five_digit_unique_number = substr(str_shuffle($uniqueid_long), 0, 5);
$final_code = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $five_digit_unique_number);
You Might Also Read : -
- How to Send Bulk Emails in java Technology.
- How to Check all Checkboxes by clicking one checkbox.
- How to Completely Disable cache for PHP project.
- How to Send data using Ajax and JavaScript into database.
- Dynamically Add Input fields into the form using JQuery.
- Magento Issues While Installing a New Installation or Theme.
- JQuery Technique for URL, How to Get QueryString parameter from URL.
- How to make and create cookie Using JavaScript Code.
0 comments :
Post a Comment