if I unset an array, would its elements be garbage collected or freed up assuming they are not referenced in anywhere else? what if I simply do $array =new array();
Following simple code answers the question:
$a = array(); $a[0] = 'a1'; $a[1] = 'b2'; foreach($a as $v) echo $v . ''; //writes content of array echo count($a) . ''; //writes 2 $a = array(); //CLEAR ARRAY foreach($a as $v) echo $v . ''; //writes nothing echo count($a) . ''; //writes 0