I had that weird thing using arrays in PHP.
$items = array();
$tools = json_decode($_GET['tools'],true);
foreach($tools as $key => $value)
{
$items[$somevar][$anothervar] = $value;
}
Then I could iterate $items
foreach($items as $key => $value)
{
//Do Something
}
But the weird part is, when I tried again to iterate through $tools with foreach, it returns NULL.
//Never Happens
foreach($tools as $key => $value)
{
//Do Something
}
Could this be caused by the Garbage Collector?
My app is running with PHP 5.2.3, Linux CentOS, Apache 2.2.
No, I doubt that this has to do with the garbage collection.
The garbage collector only removes a
zval(a PHP variable container) if therefcountis zero. This means, only if no variable-reference points to the data, it will get removed.As long as you don’t do an
unset( $tools );, the variable should be available.See http://php.net/features.gc.refcounting-basics.php for details.