Is it possible to get those values inside of function and use those outside of function here is my code:
Write return $total; inside the function
return $total;