php generate random number - Web Development and Web Design Codes

Latest

Tuesday, February 13, 2018

php generate random number

php generate random number

php generate random number
php generate random number

Hi Guys Today we are going to learn php simple script to generate random number..just follow the below examples to lean how to generate random number in php..

Examples 1: Generate random number
<?php
   $rand=mt_rand(11111,99999);
   echo $rand;
   //Output Examples: 78609
   ?>

Examples 2: Generate random number
<?php
class Random{
  public static function Numeric($length)
      {
          $chars = "1234567890";
          $clen   = strlen( $chars )-1;
          $id  = '';

          for ($i = 0; $i < $length; $i++) {
                  $id .= $chars[mt_rand(0,$clen)];
          }
          return ($id);
      }
   }
   echo Random::Numeric(6);
   ?>

That's it Guys How to generate random number in php.Keep visiting This blog for more codes ..Thank you..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.