当与SplFixedArray一起使用时,我看到了一些奇怪的行为($ arr,COUNT_RECURSIVE).以这段代码为例,......
$structure = new SplFixedArray( 10 );
for( $r = 0; $r < 10; $r++ )
{
$structure[ $r ] = new SplFixedArray( 10 );
for( $c = 0; $c < 10; $c++ )
{
$structure[ $r ][ $c ] = true;
}
}
echo count( $structure, COUNT_RECURSIVE );
Run Code Online (Sandbox Code Playgroud)
结果...
> 10
Run Code Online (Sandbox Code Playgroud)
你会期望110的结果.这是正常的行为,因为我正在嵌套SplFixedArray对象吗?