php number_format,从存储过程中隐藏空值

php number_format, hide null from stored procedure

我在 php 项目中使用 sql 服务器存储过程。在 table 中,有些列有数字,有些列只有空(在 sql 存储过程中为 NULL)。但是当我使用 number_format 时,它显示为 0。这不是我想要的,我想要空的 space。可能吗?这是我到目前为止所拥有的:

<td style="text-align: right">
<?php echo number_format($row['Quantite']) . " ";
if (is_null($row['Quantite'])){ echo ' ';}?></td>

谢谢你的帮助!

是这样的吗?

编辑 number_format (2) 的第二个参数以获得更多小数。

echo is_null($number) ? ' ' : number_format($number, 2, ",", " ") . "$ ";