| | |
Large Numbers
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 5
Reputation:
Solved Threads: 0
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!
Thanks in advance!
•
•
Join Date: Aug 2007
Posts: 189
Reputation:
Solved Threads: 14
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:
php Syntax (Toggle Plain Text)
$big_num = rand(32765, 32768). rand(32763, 32765). rand(10000, 32768). rand(32763, 32767). rand(15000, 32768). rand(18000, 32768); echo $big_num;
•
•
Join Date: Aug 2007
Posts: 189
Reputation:
Solved Threads: 14
And another method, I've created a mini function:
php Syntax (Toggle Plain Text)
function big_num() { for ($i = 1; $i <= rand(60,80); $i++) { $a .= rand(1, 32768); } return $a; } echo big_num();
Last edited by martin5211; Aug 26th, 2007 at 3:11 pm.
•
•
Join Date: Jul 2007
Posts: 5
Reputation:
Solved Threads: 0
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:
php Syntax (Toggle Plain Text)
function big_num() { for ($i = 1; $i <= rand(60,80); $i++) { $a .= rand(1, 32768); } return $a; } echo big_num();
![]() |
Similar Threads
- Store large numbers in C (C++)
- storing large numbers (C++)
Other Threads in the PHP Forum
- Previous Thread: How to insert image in MySQL.......
- Next Thread: receiving an XML Post - how to ?
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail match menu mlm mod_rewrite multiple mysql oop paypal pdf php problem protocol query radio random recursion regex remote script search server sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validation validator variable video virus votedown web window.onbeforeunload=closeme; xml youtube





