Using foreach with SplFixedArray

前端 未结 2 1604
时光取名叫无心
时光取名叫无心 2021-01-29 02:02

It seems like I can\'t iterate by reference over values in an SplFixedArray:

$spl = new SplFixedArray(10);
foreach ($spl as &$value)
{
    $value = \"string\         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 02:27

    According to the docs, the only advantage of splfixedarray() is that it is faster than a normal array. But I don't remember anyone referring to an array as slow. So your best solution is probably to switch to a regular array.

提交回复
热议问题