如何在点之后删除任何数字

wow*_*wow 2 php numbers

我想在点之后删除任何数字.例

$input = '33.892';
$input = '15.274856';
$input = '-3.14';
$input = '5.055';
Run Code Online (Sandbox Code Playgroud)

输出应该是33,15,35.让我知道.

hsz*_*hsz 7

只需将该值解析为int:

$input   = '33.892';
$input2  = '15.274856';
$input3  = '-3.14';
$input4  = '5.055';

$output  = (int) $input;
$output2 = (int) $input2;
$output3 = abs( (int) $input3 );
$output4 = (int) $input4;
Run Code Online (Sandbox Code Playgroud)

快速摘要:

  • 如果你想在点之后删除号码 - 使用 (int)
  • 如果你想删除负面标记 - 使用 abs()


fab*_*rik 5

您可能希望使用适当的修饰符使用floor()round().