How to remove 0. from 'round' PHP

-3

How do I get this 0. from the account below ..

$idMark = 6;  
$rating[5] = 4;

$bar5estrelas = ($ratings[5] == 0) ? 0 : round(($ratings[5]/$idMark), 2);

Resultado: 0.67

How do I remove the 0. leaving only 67 ?

    
asked by anonymous 04.01.2016 / 02:19

1 answer

1

I do not know how to say which is the best way to do it, because I do not know what the goal will be, since your code looks like something with a percentage but I can not be sure what you really want to do.

However you can try:

round(($ratings[5]/$idMark), 2) * 100;

Or you can try to convert to string and get 0. With str_replace (I believe that php already converts to string when using functions with str_ for example):

str_replace('0.', '', round(($ratings[5]/$idMark), 2));

But it's like I said , I do not know if it's the best way, because I do not know what the purpose of the code is.

If you're working with a percentage (which you can not be sure of because of the $ratings[5] variable) you could just do it like this:

round(($ratings[5] / $idMark) * 100);
    
04.01.2016 / 02:24