while ($row = pg_fetch_object($sql)) { $tot['tipo']=$row->tipo; $tot['sub']=$row->subtipo; array_push($total, $tot); } return $total;