我有一个数组(大),有 120 行,每行有 5 列。最后,我尝试再添加三行,但只添加最后三列。首先,我将 dummy char * 添加到要附加的行 (3) 中。在一个循环中,这三行(每三列)被添加。问题是 - 在主行末尾添加的第一行,键的顺序丢失了!!输出示例(仅显示最后一部分):
[116] => Array ( [0] => A3 [1] => B4 [2] => C2 [3] => D4 [4] => * )
[117] => Array ( [0] => A3 [1] => B5 [2] => C2 [3] => D2 [4] => * )
[118] => Array ( [0] => A3 [1] => B5 [2] => C2 [3] => D3 [4] => * )
[119] => Array ( [0] => A3 [1] => B5 [2] => C2 [3] => D4 [4] => * )
[120] => Array ( **[4]** => * [0] => * [1] => * [2] => * [3] => * ) **<==== Observer this row**
[121] => Array ( [0] => * [1] => * [2] => * [3] => * [4] => * )
[122] => Array ( [0] => * [1] => * [2] => * [3] => * [4] => * )
如果您看到第 120 行,则 [4] 出现在开头,而不是 [0]!
用于填充虚拟 * 的代码:
$i = 0;
for ($i=0;$i<=count($unMatchedRows)-1;$i++){
for ($jCols = 0; $jCols<=($pNoOfCols+$pStartCol-1); $jCols++){
$pMainArray[$vRowsOfMainArray+$i][$jCols] = '*';
}
}
用于更新最后三行的代码:
$i=0;
$ColToStart = $pStartCol-1;
foreach ($unMatchedRows as $rowNumberOfCompArray) {
for ($jCols = 0; $jCols<=$pNoOfCols; $jCols++){
echo "<br /> Value of Colstart: ".($ColToStart+$jCols);
$pMainArray[$vRowsOfMainArray+$i][$ColToStart+$jCols] = $pCompArray[$rowNumberOfCompArray][$jCols];
}
$i++;
}
$pStartCol = 3 and $pNoOfCols = 2;
行和列值的回声是否显示完美!即使在检索时,我也可以获得正确的值......就像 [0] 和 [4] 我得到了正确的值。
问题是需要在视觉环境中反馈上述数组并且它没有正确显示。
有什么帮助吗?