Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > PHP / mySQL

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 05-31-2013, 07:16 AM   #1
noahwilson
Registered User
 
Join Date: Mar 2013
Posts: 246
random number generator in php?

Hello Guys,
Please help me how can i generate random number in php? please share any related script or suggest me.
Thanks for reply.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
noahwilson is offline   Reply With Quote

Old 10-16-2013, 09:02 AM   #2
Ranjan123
Registered User
 
Join Date: Oct 2013
Posts: 15
use rand function to generate random number.
Ranjan123 is offline   Reply With Quote
Old 11-05-2013, 11:38 PM   #3
mridul
Registered User
 
Join Date: Sep 2013
Posts: 92
<?php
echo rand() . "\n";
echo rand() . "\n";

echo rand(5, 15);
?>

and u will get output like this :
7771
22264
11
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
mridul is offline   Reply With Quote
Old 03-07-2014, 02:30 AM   #4
softwin.swapna
Registered User
 
Join Date: Mar 2014
Location: India
Posts: 13
rand() simple
softwin.swapna is offline   Reply With Quote
Old 03-21-2014, 02:59 PM   #5
azraf
Registered User
 
Join Date: Mar 2014
Posts: 27
as said above, you can use rand() function.
e.g.
$v = rand(1, 999999);
It will assign the value of $v randomly between 1 to 999999.
__________________
Read free
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
and Portfolio
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
article.
Join Business Learners Community.
For IT support:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| IT Blog
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
azraf is offline   Reply With Quote
Old 03-31-2014, 12:45 PM   #6
aleksenator
Registered User
 
Join Date: Mar 2014
Posts: 2
If you need different values. You can use simple function.

<?php
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$randval = rand();
?>
aleksenator is offline   Reply With Quote
Old 04-16-2014, 05:15 AM   #7
guiltyCrown
Registered User
 
Join Date: Apr 2014
Location: UK
Posts: 15
Or for an array of randomized array

Quote:
$array = range(1,100);
shuffle($array);
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
guiltyCrown is offline   Reply With Quote
Old 05-28-2014, 02:14 AM   #8
kevinkrieger
Registered User
 
Join Date: Jan 2014
Posts: 104
int rand ( int $min , int $max ) function is to used to generate random number from the range.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
kevinkrieger is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importance of Php Development for Web Development tech.biztech Programming General 35 11-22-2019 12:37 AM
PHP introduction stevepatton PHP / mySQL 48 06-17-2019 02:02 AM
The best source of learn PHP easily at home. chikkiarora Programming General 11 02-10-2013 02:18 AM
Are you aware of the fact that PHP programming is the most widely used one? johnrichards774 PHP / mySQL 3 02-07-2012 05:41 AM
Create random 3 digit number wryfhk22 PHP / mySQL 0 09-13-2011 01:41 AM


All times are GMT -7. The time now is 08:59 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.