Since $array existed in the function, php got confused with $array_value (trying to call a variable variable). Renamed $array_value t0 $subarray