Super Web Mart - Discount Coupons & Deals - Discount Promos, Coupon Codes, Discount deals and web site reviews
 

Author Topic: random number in php  (Read 709 times)

0 Members and 1 Guest are viewing this topic.

Offline Solushunz

  • Full Member
  • ***
  • Posts: 130
    • View Profile
random number in php
« on: August 11, 2011, 11:14:35 PM »
I use this for generate random number by php code, but how to get the specific range

numbers.

Code: [Select]
<?php
echo rand() . "\n";
echo 
rand() . "\n";
?>
« Last Edit: August 11, 2011, 11:50:35 PM by seochapter »

Webmaster Forum

random number in php
« on: August 11, 2011, 11:14:35 PM »

Offline ajans

  • Jr. Member
  • **
  • Posts: 40
    • View Profile
Re: random number in php
« Reply #1 on: August 16, 2011, 10:16:26 PM »
Creating a random number takes two commands called srand and rand. srand is a preparation command for rand. It helps rand create a truely random number. rand itself creates the random number. To make a random number within a specific range, you can add the number range in the rand command brackets.

Offline whowho

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: random number in php
« Reply #2 on: September 17, 2011, 01:44:24 AM »
try the following code.

rand(min,max), it will give you the number betweent min and max

Offline jbard

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Web Partner Group
Re: random number in php
« Reply #3 on: December 17, 2011, 08:22:36 PM »
To create random numbers in PHP, you can use the rand() function call, which takes either zero or, optionally, two parameters determining the minimum and maximum random numbers (inclusive) that you'd like. If you don't specify a maximum then it will default to a value, RAND_MAX, set in the PHP configuration. The function returns an integer, generated "randomly." (Computers can't generate real random numbers, but this tries and is suitable for most purposes.)

Webmaster Forum

Re: random number in php
« Reply #3 on: December 17, 2011, 08:22:36 PM »