[英]not show decimals in PHP Value?
I have a web made in laravel, livewire and I need to hide decimals in variable: 'valor' => $countPoblacion->poblacion] since it is currently showing decimals in all values.我有一个 web laravel,livewire,我需要在变量中隐藏小数:'valor'=> $countPoblacion->poblacion] 因为它当前在所有值中显示小数。
class ConteoPoblacion extends Conteo
{
protected function cargarDatos($args = null)
{
if ($this->tieneArgumento('idMunicipio', $args))
{
$countPoblacion = Distrito::select(
DB::raw('SUM(poblacion) as poblacion'),
DB::raw('SUM(km2) as km2'),
)
->where('id', '=', $args['idMunicipio'])
->first();
return [
['nombre' => 'poblacion', 'valor' => $countPoblacion->poblacion],
['nombre' => 'densidad (hab/km2)', 'valor' => $countPoblacion->poblacion / $countPoblacion->km2],
['nombre' => 'superficie en km2', 'valor' => $countPoblacion->km2],
];
} else if ($this->tieneArgumento('idSeccion', $args))
{
$countPoblacion = Distrito::select(
DB::raw('SUM(poblacion) as poblacion'),
DB::raw('SUM(km2) as km2'),
)
->where('seccion_id', '=', $args['idSeccion'])
->first();
return [
['nombre' => 'poblacion', 'valor' => $countPoblacion->poblacion],
['nombre' => 'densidad (hab/km2)', 'valor' => $countPoblacion->poblacion / $countPoblacion->km2],
['nombre' => 'superficie en km2', 'valor' => $countPoblacion->km2],
];
}
}
}
Did you try rounding the numbers?你试过四舍五入吗? Using any of these functions使用这些功能中的任何一个
round()
floor()
or或者
ceil()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.