Jump to content

randomly generated number


ibanez270dx

Recommended Posts

here are a couple options:
[code]
<?php
// randomly generate and concatonate 11 digits
$sku = '';
for ($i = 0; $i < 11; $i++) {
  $num = rand(0,9);
  $sku .= $num;
}
echo $sku;


// randomly generate the entire number and pad with leading zeros
echo sprintf("%011d", rand(0,99999999999));
?>
[/code]

hope this helps
[quote author=Barand link=topic=105619.msg422611#msg422611 date=1156636418]
However, as the max value of an integer is 2,147,483,647 (10 digits) I'd go with Obsidian's first method
[/quote]'

If the max size of an integer is 10 digits - the max value is 2,147,483,647? Can you tell me how you calculate that? Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.