The easiest way is just to typecast the number like this:
$_SESSION['minicart'] = $minicartTotal = money_format("%n", (double)$cartTotal);
But the best way is to make sure that $price
is a double and $each_item['quantity']
is a integer because they are the only unknown variables in your example and if they aren't those types you will get that error.