PHP向从load函数接收的变量添加点


php add dots to a variable received from load function

我通过jquery接收一个变量

var x = 15;
$("#block").load("file.php", {n:x});

当我试图使用它

$i=$_POST['n'];  
echo $i; 

i receive that .15.

我的问题是-如何删除这些点。

删除点:

<?php
$i = trim($_POST['n']);
// delete first dot (if exists)
if(substr($i, 0, 1) == '.') $i = substr($i, 1);
// delete last dot (if exists)
if(substr($i, -1) == '.') $i = substr($i, 0, -1);
echo $i;
?>