Is it possible to specify a decimal range with a phprand function?

Asked 2 years ago, Updated 2 years ago, 79 views

I want to designate latitude and longitude as Busan range, so I want 35.xxxx /129.xxx decimal point to be random

php rand primes

2022-09-20 15:48

1 Answers

Don't be complicated, just pick random numbers between moderately large numbers and divide them into moderately large numbers.

$long = random_int(35 * 1000000, 36 * 1000000);
var_dump($long / 1000000);

PS. random_int() is recommended for obtaining arbitrary integers. Some names are prettier than rand(), but this is more cryptographically secure.


2022-09-20 15:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.