John Davidson

random - Generate 7 digit number similar to original number in PHP

0 comments
Message:


I would like to generate 7 digit number that is very similar to the original randomized number in PHP.


The purpose is: the original randomized number simulates the telephone number that is used in a sound game where users identifies the correct number while listening to the audio.


Using loop


$original_randomized_number=rand(1000000,9999999);
for ($x = 1; $x <= 3; $x++) {
$generated_telephones[$x] = rand(1000000,9999999);
}

to generate 3 random telephone numbers works, but it is too simple to identify the correct number.


F.e. the original randomized number 9876543 - the desired result similar to - 9865742, 8896558, 9586543



My Answer:
= 100; $x++) {
$similar_number = $original_randomized_number + rand(-1000, 1000);
echo $similar_number . "
";
}

Rate this post

5 of 5 based on 1569 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us