小编wlv*_*vrn的帖子

PHP COUNT_RECURSIVE和SplFixedArray

当与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对象吗?

php spl

4
推荐指数
1
解决办法
378
查看次数

标签 统计

php ×1

spl ×1