[eluser]kyleect[/eluser]
Ok, this is a little complicated to explain so I will put down my code first.
Here is what I have:
Code:
<?php
header('Content-Type: text/plain');
$hours = array();
for ($a=0; $a < 35; $a++) {
$hours[$a] = array();
for ($b=0; $b < 6; $b++) {
$seconds = mt_rand(1, 5);
$hours[$a][$b] = '0:0:'.$seconds;
}
echo (implode("\t", $hours[$a]))."\n";
}
?>
This fills $hours with 34 entries, each with an array of 6 random numbers between 1-5. Ok, that works. Looks like this:
Quote:0:0:3 0:0:2 0:0:1 0:0:3 0:0:3 0:0:3
0:0:5 0:0:4 0:0:5 0:0:3 0:0:2 0:0:5
0:0:1 0:0:2 0:0:3 0:0:3 0:0:4 0:0:1
0:0:4 0:0:1 0:0:5 0:0:5 0:0:3 0:0:4
0:0:1 0:0:1 0:0:2 0:0:1 0:0:4 0:0:5
0:0:4 0:0:4 0:0:2 0:0:4 0:0:3 0:0:3
0:0:2 0:0:4 0:0:3 0:0:1 0:0:2 0:0:4
0:0:1 0:0:1 0:0:2 0:0:5 0:0:2 0:0:1
0:0:1 0:0:3 0:0:5 0:0:4 0:0:1 0:0:2
0:0:3 0:0:4 0:0:3 0:0:1 0:0:4 0:0:1
0:0:4 0:0:3 0:0:4 0:0:2 0:0:1 0:0:5
0:0:2 0:0:2 0:0:1 0:0:1 0:0:3 0:0:4
0:0:1 0:0:2 0:0:5 0:0:2 0:0:5 0:0:1
0:0:4 0:0:3 0:0:5 0:0:5 0:0:4 0:0:2
0:0:5 0:0:3 0:0:2 0:0:1 0:0:4 0:0:1
0:0:4 0:0:4 0:0:3 0:0:1 0:0:5 0:0:1
0:0:2 0:0:1 0:0:1 0:0:1 0:0:2 0:0:2
0:0:4 0:0:3 0:0:4 0:0:3 0:0:1 0:0:3
0:0:2 0:0:5 0:0:2 0:0:2 0:0:5 0:0:5
0:0:5 0:0:3 0:0:2 0:0:1 0:0:4 0:0:5
0:0:5 0:0:4 0:0:5 0:0:2 0:0:1 0:0:4
0:0:2 0:0:5 0:0:1 0:0:1 0:0:2 0:0:5
0:0:5 0:0:3 0:0:5 0:0:3 0:0:4 0:0:3
0:0:2 0:0:2 0:0:1 0:0:3 0:0:4 0:0:1
0:0:2 0:0:3 0:0:2 0:0:4 0:0:5 0:0:5
0:0:2 0:0:4 0:0:5 0:0:3 0:0:1 0:0:2
0:0:2 0:0:3 0:0:5 0:0:2 0:0:5 0:0:4
0:0:1 0:0:5 0:0:2 0:0:2 0:0:2 0:0:1
0:0:2 0:0:1 0:0:1 0:0:4 0:0:4 0:0:2
0:0:4 0:0:1 0:0:2 0:0:3 0:0:2 0:0:5
0:0:1 0:0:3 0:0:5 0:0:1 0:0:1 0:0:5
0:0:4 0:0:4 0:0:1 0:0:4 0:0:2 0:0:1
0:0:2 0:0:4 0:0:5 0:0:5 0:0:4 0:0:2
0:0:4 0:0:4 0:0:5 0:0:1 0:0:2 0:0:4
0:0:5 0:0:1 0:0:4 0:0:5 0:0:1 0:0:5
There is a problem though. On each of those lines, if each of those values are above 5, the value in the same place on the next line has to be 4 or below. I'm having issues with this. Here is what I've tried and what I've gotten:
Code:
<?php
header('Content-Type: text/plain');
$hours = array();
for ($a=0; $a < 35; $a++) {
$hours[$a] = array();
for ($b=0; $b < 6; $b++) {
$previous = $a - 1;
if($hours[$previous] > 5){
$seconds = mt_rand(1, 5);
}else{
$seconds = mt_rand(1, 10);
}
$hours[$a][$b] = '0:0:'.$seconds;
}
echo (implode("\t", $hours[$a]))."\n";
}
?>
Quote:<br />
<b>Notice</b>: Undefined offset: -1 in <b>/Users/k/htdocs/gen.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>: Undefined offset: -1 in <b>/Users/k/htdocs/gen.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>: Undefined offset: -1 in <b>/Users/k/htdocs/gen.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>: Undefined offset: -1 in <b>/Users/k/htdocs/gen.php</b> on line <b>12</b><br />
<br />
<b>Notice</b>: Undefined offset: -1 in <b>/Users/k/htdocs/gen.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