number_format() causes error "A non well formed numeric value encountered"
Try type casting first parameter of number_format() to float:
$format = number_format((float)0, 2);
or
$format = number_format(floatval(0), 2);
Try to replace decimal point and after that cast to float.
var_dump((float)number_format((float)str_replace(",", ".", "20,5"), 2, ".", ""));
result: float(20.5);
Without replacing:
var_dump((float)number_format(floatval("20,5"), 2, ".", ""));
result: float(20);
var_dump((float)number_format((float) "20,5", 2, ".", ""));
result: float(20);