【发布时间】:2012-09-05 15:25:30
【问题描述】:
当与 SplFixedArray 一起使用时,我看到 count($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 );
结果...
> 10
您会期望结果为 110。这是因为我嵌套了 SplFixedArray 对象而导致的正常行为吗?
【问题讨论】: