你想过用foreach循环替换for循环吗?
如:
foreach( $tests as $i => $test )
这样做的好处是在$test[$i]中有一个值。然后,在你的
$test[ $i ][ $j ] == null
阻止,放置此:
if ($j != $k &&
// I suspect that this will cause errors too.
// Do yourself a favor and add this sanity check.
isset( $test[$j] ) && $test[$j] != null &&
isset( $test[$k] ) && $test[$k] != null) {
$currentK = $test[$k];
$currentJ = $test[$j];
// Use debug lines if setting things directly won't work
if( !isset( $coin[ $currentJ ] ) || !is_array( $coin[ $currentJ ] ) )
{
// $coin[ $currentJ ] = array();
die( "
$currentK $currentJ \n" . print_r( $coin ) );
}
$currentCoin =& $coin[ $currentJ ];
if( !isset( $currentCoin [ $currentK ] ) ||
!is_array( $currentCoin [ $currentK ] ) )
{
// Just curious, but when doing these checks before,
// did you remember to assign a numeric value here?
//
// $currentCoin[ $currentK ] = 0;
die( "
$currentK $currentJ \n" . print_r( $coin ) );
}
$currentCoin[ $currentK ] += 1 / ($some_var - 1);
}
}