Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Percentages in PHP

edited May 2007 in Vanilla 1.0 Help
First of all let me say that, as a student in elementary school I had problems with mathematics.

Secondly, I know very little PHP and what I do know is hacked from other sources.

The problem...
    I have 130 people visit my site.
    65 of them have made comments.

Now even I know that's 50% of them, but what equation in PHP would I use to work it out?

Posted: Thursday, 3 May 2007 at 1:16PM


  • Options
    (65/130) * 100
  • Options
    Thanks mate, the formula wasn't the problem, it was the syntax, structure and the rounding of the decimals.
    In case anyone else is interested...
    <?php $visitors = 130; $commentors = 65; echo 'Visitors: '.$visitors; echo'<br>'; echo 'Commenters: '.$commentors; echo'<br>'; $percy = round(($commentors/$visitors)*100, 0); echo $percy.'% of visitors have made comments'; ?>

    Posted: Thursday, 3 May 2007 at 2:07PM

  • Options
    excellent job Wanderer: i could probably use this.
This discussion has been closed.