Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1045371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:58:30+00:00 2026-05-16T15:58:30+00:00

i wrote a php script to generate random values between 1 and 99999999999999999999 (that’s

  • 0

i wrote a php script to generate random values between 1 and 99999999999999999999 (that’s 20 9’s).

The script is like this:

$maxq=20;
for($i=1;$i<=$maxq;$i++) {
    $min=pow(10,$i);
    $max=(pow(10,$i)*10)-1;
    echo $min."<br>";
    echo $max."<br>";
    echo mt_rand($min,$max)."<br>----<br>";
}

but after 10 digit, php generates scientific notations like 1.0E+19 and the random numbers generated are a mess.

I guess think is because of my hardware imitations (OS: Win XP 32 bit).

What can i do to over come this? any help?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:58:31+00:00Added an answer on May 16, 2026 at 3:58 pm

    You could generate n random digits and concatenate them into one large string.

    function randomDigits($numDigits) {
        if ($numDigits <= 0) {
            return '';
        }
    
        return mt_rand(0, 9) . randomDigits($numDigits - 1);
    }
    
    // Or an iterative approach
    function randomDigitsLame($numDigits) {
        $digits = '';
    
        for ($i = 0; $i < $numDigits; ++$i) {
            $digits .= mt_rand(0, 9);
        }
    
        return $digits;
    }
    
    $maxq = 20;
    
    for ($i = 1; $i <= $maxq; $i++) {
        echo $i . "<br>\n";
        echo randomDigits($i) . "<br>\n----<br>\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a php script that must be run on the php interpreter (Without
I'm using Dynatree for the first time and wrote a PHP script that returns
I wrote a PHP-CLI script that mixes two audio (.WAV PCM) files (with some
Can someone write a PHP script that reproduces the functionality of this linux shell
I have wrote this little script which generates a nice random password. The problem
I'm trying to write a php script that will generate a variety of new
I have been using this simple script to generate images from text: <?php header('Content-type:
I've got a form like this: <form name=htmlform method=post action=script/gen.php?postData> <table width=450px> </tr> <tr>
I wrote a PHP script to list all the tables present in the database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.