Hello. I am currently having a problem with a script. I am using the rand() function to make big randomized numbers. The problem is that rand() only returns numbers lower than about 2 billion. I need more than that. Is there any function in PHP that gives you REALLY BIG randomized numbers? Or do you know a custom made script for this?

Thanks in advance!

Recommended Answers

All 3 Replies

I don't know if it possible, because there are a limit in rand() and the processor, but if you really want only large numbers you could concatenate them with dots and min and max parameters, like:

$big_num = rand(32765, 32768). rand(32763, 32765). rand(10000, 32768). rand(32763, 32767). rand(15000, 32768). rand(18000, 32768);

echo $big_num;

And another method, I've created a mini function:

function big_num() {
	
	for ($i = 1; $i <= rand(60,80); $i++) {
		$a .= rand(1, 32768);
	}
	
	return $a;
}

echo big_num();

It worked. Thank you a million times!!! You don't know how gratefull I am to you...

And another method, I've created a mini function:

function big_num() {
	
	for ($i = 1; $i <= rand(60,80); $i++) {
		$a .= rand(1, 32768);
	}
	
	return $a;
}

echo big_num();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.