When the run the following code, everything works fine until $i = 5. After that I get Uninitialized string offset notices, even though the arrays seem to be getting populated correctly. I get this notice when running locally but not when I check it on the remote server. Both are running v5.2.11. I assume the output is different from local to remote based on error reporting configs, but what is causing the notice?
Code:
$i = 0;
$row = 0;
$col = 0;
$quad = 0;
while(count($ripDigits) > 0)
{
$ranNum = rand(0, count($ripDigits) - 1);
$ripDigit_splice = array_splice($ripDigits, $ranNum, 1);
$ranDigit = $ripDigit_splice[0];
echo ("\$i = " . $i . " | count(\$ripDigits) = " . count($ripDigits) . "<br />\n");
$thisRow = "row_" . $row;
$$thisRow[$i] = $ranDigit;
echo ("\t\t<td><b>" . $$thisRow[$i] . "</b></td>\n");
$thisUsedColumn = "usedDigits_column_" . $i;
$$thisUsedColumn[$col] = $$thisRow[$i];
$thisUsedColumn = "usedDigits_quad_" . $i;
$$thisUsedColumn[$quad] = $$thisRow[$i];
$i++;
}
Output:
$i = 0 | count($ripDigits) = 8
$i = 1 | count($ripDigits) = 7
$i = 2 | count($ripDigits) = 6
$i = 3 | count($ripDigits) = 5
$i = 4 | count($ripDigits) = 4
$i = 5 | count($ripDigits) = 3
Notice: Uninitialized string offset: 5 in script.php on line 97
Notice: Uninitialized string offset: 5 in script.php on line 99
Notice: Uninitialized string offset: 5 in script.php on line 102
Notice: Uninitialized string offset: 5 in script.php on line 105
$i = 6 | count($ripDigits) = 2
Notice: Uninitialized string offset: 6 in script.php on line 97
Notice: Uninitialized string offset: 6 in script.php on line 99
Notice: Uninitialized string offset: 6 in script.php on line 102
Notice: Uninitialized string offset: 6 in script.php on line 105
$i = 7 | count($ripDigits) = 1
Notice: Uninitialized string offset: 7 in script.php on line 97
Notice: Uninitialized string offset: 7 in script.php on line 99
Notice: Uninitialized string offset: 7 in script.php on line 102
Notice: Uninitialized string offset: 7 in script.php on line 105
$i = 8 | count($ripDigits) = 0
Notice: Uninitialized string offset: 8 in script.php on line 97
Notice: Uninitialized string offset: 8 in script.php on line 99
Notice: Uninitialized string offset: 8 in script.php on line 102
Notice: Uninitialized string offset: 8 in script.php on line 105
1 8 4 2 7 5 9 3 6
Thanks in advance!