serginhosant Posted July 29, 2004 Report Share Posted July 29, 2004 Gente,estou fazendo uma conta matemática aqui para retornar a porcentagem dos votos de uma enquete...bom, a questão é que o resultado está assim:41.125463545%queria exibir só números inteirosassim:41%obrigado Quote Link to comment Share on other sites More sharing options...
0 jhonnywg Posted July 29, 2004 Report Share Posted July 29, 2004 Gente,estou fazendo uma conta matemática aqui para retornar a porcentagem dos votos de uma enquete...bom, a questão é que o resultado está assim:41.125463545%queria exibir só números inteirosassim:41%obrigado coleque godigo na tela pra que eu psa dar uma olhado!!! Quote Link to comment Share on other sites More sharing options...
0 jhonnywg Posted July 29, 2004 Report Share Posted July 29, 2004 coloque o godigo na tela eu so novato mais vendo o godigo poso te ajudar Quote Link to comment Share on other sites More sharing options...
0 taudujas Posted July 29, 2004 Report Share Posted July 29, 2004 Usa expressões regulares. Quote Link to comment Share on other sites More sharing options...
0 jhonnywg Posted July 29, 2004 Report Share Posted July 29, 2004 tente colocar .number_format( a variavel que você ta emprimindo ,2) Quote Link to comment Share on other sites More sharing options...
0 serginhosant Posted July 29, 2004 Author Report Share Posted July 29, 2004 jhonnywg obrigado.........dei uma pesquisada lá no imaster e encontrei um artigo que ensina direitinhoheheheheheclique aqui para ver o artigo Quote Link to comment Share on other sites More sharing options...
0 doulo4ever Posted July 29, 2004 Report Share Posted July 29, 2004 $porcentagem = 41.125463545;$formatado = round($porcentagem);echo "$formatado%"; Quote Link to comment Share on other sites More sharing options...
0 Fabyo Posted July 30, 2004 Report Share Posted July 30, 2004 $valor = 41.125463545;$valor = ceil($valor);http://br.php.net/ceil Quote Link to comment Share on other sites More sharing options...
0 ppgsalomao Posted July 30, 2004 Report Share Posted July 30, 2004 Tb pode converter o tipo da variável para integer com o settype ou simplismente colocando (int) $var; Quote Link to comment Share on other sites More sharing options...
0 Gladisson Posted July 30, 2004 Report Share Posted July 30, 2004 $valor = 41.125463545;echo round($valor,2); // Vai retornar 41.12 Quote Link to comment Share on other sites More sharing options...
Question
serginhosant
Gente,
estou fazendo uma conta matemática aqui para retornar a porcentagem dos votos de uma enquete...
bom, a questão é que o resultado está assim:
41.125463545%
queria exibir só números inteiros
assim:
41%
obrigado
Link to comment
Share on other sites
9 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.