如何在php中设置数组中的逗号?

如何在php中设置数组中的逗号?,php,api,Php,Api,在我当前的项目中,我有一个数组,例如118个输出。在118的第一个数字后面,我想插入一个逗号 我已经尝试使用number_format函数来放置逗号,但它总是将逗号放在数组的末尾 我当前的代码: $api = "https://r6tab.com/api/player.php?p_id="; $scenus = "3bb8d3bc-ab7a-45fb-8154-ed54897b2c4c"; $api_response_1 = file_get_contents($api.$scenus);

在我当前的项目中,我有一个数组,例如118个输出。在118的第一个数字后面,我想插入一个逗号

我已经尝试使用number_format函数来放置逗号,但它总是将逗号放在数组的末尾

我当前的代码:

$api = "https://r6tab.com/api/player.php?p_id=";
$scenus = "3bb8d3bc-ab7a-45fb-8154-ed54897b2c4c";

$api_response_1 = file_get_contents($api.$scenus);

$scenus_kd = $api_response_1_decoded['kd'];


... <h4><?php echo number_format($scenus_kd, 2); ?></h4> ....

数字格式不插入小数点或逗号。它把数字四舍五入。你曾经

number_format($scenus_kd,2)
这将118四舍五入到小数点后两位,即118.00。如果要将118转换为1.18,需要将其除以100:

number_format($scenus_kd/100,2)

原来的数字是什么样子的?$scenus\u kd中的一个?没有数字格式的原始数字是118。您可能只需要使用数字格式$scenus\u kd/100,2
number_format($scenus_kd/100,2)