gpt4 book ai didi

php - 将逗号放在 PHP 数字变量中

转载 作者:行者123 更新时间:2023-11-29 06:31:04 24 4
gpt4 key购买 nike

我在我的 header.php 中使用一个脚本来显示注册的用户数量(例如,它显示 79447 个玩家),但我希望它显示 79,447 个玩家。我将如何添加逗号?我尝试了几种方法但都失败了。

<?php
include('session.php');
?>

<style>
.navbar {
font-family: 'Numans', sans-serif;
text-transform: uppercase;
}
.navbar-inverse {
background: #00aa00;
}
.dropdown-menu li a:hover, .dropdown-menu-default li a:hover {
color: #00aa00;
}
.dropdown-menu {
min-width: 100%;
border-radius: 0px;
}
.navbar .navbar-form .form-control-wrapper .form-control, .navbar .navbar-form .form-control {
text-transform: uppercase;
}
.nav>li>a>img {
max-width: 20px;
margin-right: 4px;
}
</style>

<div class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-inverse-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://epicmc.us">EPICMC</a>
</div>
<div class="navbar-collapse collapse navbar-inverse-collapse">
<ul class="nav navbar-nav">
<li><a href="https://epicmc.us/">HOME</a></li>
<?php $remote_api = file_get_contents('http://epicmc.us/api.php?task=total'); $remote_job = json_decode($remote_api); echo '<li>'; echo '<a href="javascript:void(0)">'; echo substr($remote_job->amount,0,75); ?> PLAYERS</li></a>
<li class="dropdown">
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" action ="stats.php" method="GET"><input type="text" name="player" class="form-control col-lg-8" autocomplete="off" placeholder="USERNAME"></form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
<img src="https://minepic.org/avatar/20/<?php echo strtoupper($_SESSION['login_user']); ?>">
<?php if(isset($_SESSION['login_user'])){
echo "HOWDY, ";
echo strtoupper($_SESSION['login_user']);
} else {
Echo "HOWDY, GUEST";
}?><b class="caret"></b></a>
<ul class="dropdown-menu">
<?php if(isset($_SESSION['login_user'])){
echo '<li><a href="https://epicmc.us/login.php">ACCOUNT</a></li>';
echo '<li><a href="#">NOTIFICATIONS <span class="badge">0</span></a></li>';
echo '<li><a href="https://epicmc.us/logout.php">LOGOUT</a></li>';
} else {
echo '<li><a href="https://epicmc.us/login.php">LOGIN</a></li>';
}?>
</ul>
</li>
</ul>
</div>
</div>

最佳答案

从代码片段来看,用户数量似乎在变量 $remote_job->amount

echo number_format($remote_job->amount);

http://php.net/manual/en/function.number-format.php

关于php - 将逗号放在 PHP 数字变量中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27885438/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com