Using foreach with SplFixedArray
问题 It seems like I can't iterate by reference over values in an SplFixedArray: $spl = new SplFixedArray(10); foreach ($spl as &$value) { $value = "string"; } var_dump($spl); Outputs: Fatal error: Uncaught exception 'RuntimeException' with message 'An iterator cannot be used with foreach by reference' Any workaround? 回答1: Any workaround? Short answer: don't iterate-by-reference. This is an exception thrown by almost all of PHP's iterators (there are very few exceptions to this exception); it isn