OiO.lk Blog PHP Can not get the numbers to be random
PHP

Can not get the numbers to be random


I also and want to fill by zeroes up to 1000

This is my code:

<?php
$randarr = array();
for ($i = 0; $i < 9999; $i++) {
array_push($randarr, $i);
}
shuffle($randarr);

$max_columns = 15;

$record_id=0;

while(true)
{
for ($column = 1; $column<=$max_columns; $column++){
if (!isset($randarr[$record_id])){  
return; 
}

echo $record_id;
echo " ";
if ($column == $max_columns){
echo "\r\n";
}    
$record_id++;
}
}
?>

Look like this:

1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529

1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544

How to modify the code to fit my needs?
Regards, Ralph



You need to sign in to view this answers

Exit mobile version