📜  进度条计算百分比php代码示例

📅  最后修改于: 2022-03-11 14:54:05.139000             🧑  作者: Mango

代码示例1
$playerson = (int)preg_replace( '/[^0-9]/', '', $data[4]);
$maxplayers = (int)preg_replace( '/[^0-9]/', '', $data[5]);
// $percentage = floor($playerson / $maxplayers) * 100; // floor (round down) optional
// for echap to division by 0 add IF short form
($maxplayers > 0) ?  $percentage = floor($playerson / $maxplayers) * 100 : 0;