Quantcast
Channel: Why does foreach increase refcount by 2 instead of 1? - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by user2417483 for Why does foreach increase refcount by 2 instead of 1?

The xdebug_debug_zval() is looking at the $array variable and not the $key variable.if you change your code to:foreach ($array as $key => $value) { echo $key . " : " . $values . "<br>";...

View Article



Why does foreach increase refcount by 2 instead of 1?

NikiC stated in another thread:Right before [a foreach] iteration the $array is "soft copied" for use in foreach. This means that no actual copy is done, but only the refcount of the zval of $array is...

View Article
Browsing all 2 articles
Browse latest View live




Latest Images