title: Simple PHP Simulation Script
body: <p>I'm working on making a simple simulation for my website, and I've looked around but cannot find anything on how to accomplish this. Could someone please provide how I would achieve the following output with code:</p>
  
  <hr>
  
  <p>There are two players, both level 2.</p>
  
  <p><strong>Player 1</strong></p>
  
  <p>Attack - 1
  Defense - 2
  Health - 10</p>
  
  <p><strong>Player 1</strong></p>
  
  <p>Attack - 2
  Defense - 1
  Health - 10</p>
  
  <p>I want to to have a simulated turn-based battle between these two players. It would randomly choose who gets the first hit. For this we'll say player 1 goes first. 
  The equation I would use to calculate the hit would be <code>($playerattack/$playerdefense) + rand(1,$level)</code> (equation may work well, may not. just for testing purposes) I want to then have output like the following.</p>
  
  <p>Player 1 (10 health) - hit a 2</p>
  
  <p>Player 2 (8 health) - hit a 1</p>
  
  <p>. . . </p>
  
  <p>Player 1 (1 health) - hit a 2</p>
  
  <p><strong>Player 2 dies, Player 1 is victorious!</strong></p>
  
  <p>**Sorry to those who answered to the old example! Thanks for your feedback though</p>