我正在以这种格式2.00
获得价值。我想将值显示为2
。我怎样才能使用php?我从数据库获取价值的代码如下,我正在使用floor
函数,但evrytime我得到了值0
。
码
while ($row = oci_fetch_array($rcv, OCI_ASSOC+OCI_RETURN_NULLS))$basic_info[]=$row;
foreach ($basic_info as $x)
{
$serial=$x['SERIAL'];
$in = floor($serial);
}
echo "$in"
数据库中的值:
2.00
所需的输出:
2
currentoutput:
0
答案 0 :(得分:0)
使用number_format()
代替
number_format($x['SERIAL'], 0);
答案 1 :(得分:0)
您可以在$in
中转换int
值。
while ($row = oci_fetch_array($rcv, OCI_ASSOC+OCI_RETURN_NULLS))$basic_info[]=$row;
foreach ($basic_info as $x)
{
$serial=$x['SERIAL'];
$in = floor($serial);
}
echo (int)$in; // here is change.
答案 2 :(得分:0)
使用类型转换。
<div data-dojo-type="dojo/data/ItemFileWriteStore" data-dojo-id="jsonStore_3" data-dojo-props="url:'test.do?businessId=${approvalProcess.businessId}'">
<script type="dojo/connect" data-dojo-event="onNew" data-dojo-args="newItem">
insertApprovalNotificationHandler(this,newItem);
</script>
</div>
<table data-dojo-type="dojox.grid.DataGrid"
data-dojo-id="grid_3" id="grid_3"
store="jsonStore_3"
query="{ recipientName: '*' }"
rowsPerPage="20" rowSelector="20px"
region="center"
style="width: 100%;">
</table>
<script>
var test = function() {
jsonStore_3.newItem({sample1: 'aa', sample2:'bb'});
}
var insertApprovalNotificationHandler = function (object,newItem){
console.log("TEST");
}
</script>
或者
$in = intval($serial);
答案 3 :(得分:0)
while($ row = oci_fetch_array($ rcv,OCI_ASSOC + OCI_RETURN_NULLS))$ basic_info [] = $ row;
foreach($ basic_info as $ x){$ serial = $ x ['SERIAL'];
$ in =(int)$ serial;} echo“$ in”;