我正在使用laravel进行编码。现在,我将价格另存为123.45
,当我回显它时,我得到的是相同的东西,这是正确的,我希望将其保存在数据库中。我的问题是,为了使我能够使某个人支付一定的金额,我需要删除该期间,以使其看起来像这样12345
。
我不知道自己是否搜索不正确,但是找不到解决方法。
答案 0 :(得分:0)
我不确定,但是如果您只是想从十进制数字中删除句点,则可以尝试使用PHP的函数str_replace():
$x = 245.25;
$x = str_replace('.', '', $x);
echo $x;
// output
24525
这将提供除去小数点的所有数字。
答案 1 :(得分:0)
您可以使用php round()
函数:
echo round(123.45, 0); // 123
echo round(123.55, 0); // 124
如果不是您想要的,可以使用@Shiv
解决方案
答案 2 :(得分:0)
@Nikki
如果要以分存储金额,则将金额乘以100
@tela.event
def on_draw():
global pos, comando, rotX, rotY, parede, chao, Dchao, Dparede
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
if comando["w"] == 1:
pos[2] += math.cos(math.pi*rotX/180)
pos[0] += math.sin(math.pi*rotX/180)
if comando["s"] == 1:
pos[2] -= math.cos(math.pi*rotX/180)
pos[0] -= math.sin(math.pi*rotX/180)
if comando["d"] == 1:
pos[2] += math.sin(math.pi*rotX/180)
pos[0] -= math.cos(math.pi*rotX/180)
if comando["a"] == 1:
pos[2] -= math.sin(math.pi*rotX/180)
pos[0] += math.cos(math.pi*rotX/180)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, 1, 0.1, 1000)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
if pos[0] < -188:
pos[0] = -188
if pos[2] < -188:
pos[2] = -188
if pos[0] > 188:
pos[0] = 188
if pos[2] > 188:
pos[2] = 188
glLightfv(GL_LIGHT0, GL_POSITION, (GLfloat*4)(0,0,0,1))
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, (GLfloat*3)(0, 0, -1))
glLightfv(GL_LIGHT0, GL_SPOT_CUTOFF, (GLfloat*1)(45))
gluLookAt(pos[0], pos[1], pos[2], pos[0]+math.sin(math.pi*rotX/180), pos[1]+math.cos(math.pi*rotY/180), pos[2]+math.cos(math.pi*rotX/180), 0, 10, 0)
glLightfv(GL_LIGHT0, GL_AMBIENT, (GLfloat*4)(0.2,0.2,0.2,1))
glLightfv(GL_LIGHT0, GL_DIFFUSE, (GLfloat*4)(0.8,0.8,0.8,1))
glLightfv(GL_LIGHT0, GL_SPECULAR, (GLfloat*4)(1,1,1,1))
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, (GLfloat*1)(100))
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (GLfloat*4)(1,1,1,1))
glBindTexture(GL_TEXTURE_2D, chao.id)
glUseProgram(program)
# chão
glBegin(GL_POLYGON)
glNormal3f(0, 1, 0)
glTexCoord2f(0,0)
glVertex3f(-200,-20,200)
glTexCoord2f(0,10)
glVertex3f(-200,-20,-200)
glTexCoord2f(10,10)
glVertex3f(200,-20,-200)
glTexCoord2f(10,0)
glVertex3f(200,-20,200)
glEnd()
glBindTexture(GL_TEXTURE_2D, parede.id)
# teto
glBegin(GL_POLYGON)
glNormal3f(0, -1, 0)
glTexCoord2f(0,0)
glVertex3f(-200,20,200)
glTexCoord2f(0,10)
glVertex3f(-200,20,-200)
glTexCoord2f(10,10)
glVertex3f(200,20,-200)
glTexCoord2f(10,0)
glVertex3f(200,20,200)
glEnd()
# parede
glBegin(GL_POLYGON)
glNormal3f(-1, 0, 0)
glTexCoord2f(0,0)
glVertex3f(-200,20,200)
glTexCoord2f(10,0)
glVertex3f(-200,20,-200)
glTexCoord2f(10,1)
glVertex3f(-200,-20,-200)
glTexCoord2f(0,1)
glVertex3f(-200,-20,200)
glEnd()
# parede
glBegin(GL_POLYGON)
glNormal3f(0, 0, 1)
glTexCoord2f(0,0)
glVertex3f(-200,-20,-200)
glTexCoord2f(10,0)
glVertex3f(200,-20,-200)
glTexCoord2f(10,1)
glVertex3f(200,20,-200)
glTexCoord2f(0,1)
glVertex3f(-200,20,-200)
glEnd()
# parede
glBegin(GL_POLYGON)
glNormal3f(-1, 0, 0)
glTexCoord2f(0,0)
glVertex3f(200,-20,-200)
glTexCoord2f(10,0)
glVertex3f(200,-20,200)
glTexCoord2f(10,1)
glVertex3f(200,20,200)
glTexCoord2f(0,1)
glVertex3f(200,20,-200)
glEnd()
# parede
glBegin(GL_POLYGON)
glNormal3f(0, 0, 1)
glTexCoord2f(0,0)
glVertex3f(-200,-20,200)
glTexCoord2f(10,0)
glVertex3f(200,-20,200)
glTexCoord2f(10,1)
glVertex3f(200,20,200)
glTexCoord2f(0,1)
glVertex3f(-200,20,200)
glEnd()
或者,如果您只想删除$price = 123.45 * 100;
// output
12345
,请尝试这样
.