title: How do I store the values of a for loop in an array?
body: <p>I'm completely new to programming and have been struggling with this for at least a couple of hours. It simply deals 5 cards to a player. This is the code I have:</p>
  
  <pre><code>&lt;?php
  //setting up arrays
  $cardLocation = array();
  $suits = array("Hearts", "Diamonds", "Spades", "Clubs");
  $ranks = array("Ace", 2, 3, 4, 5, 6, 7, 8, 9, 10, "Jack","Queen", "King");
  
  //filling the deck
  for($rank=0; $rank&lt;13; $rank++){
    for($suit=0; $suit&lt;4; $suit++){
      $cardLocation[$rank][$suit] = "deck";
    }
  }
  
  //dealing the cards to a player
  for($i=0; $i&lt;5; $i++){
  
  $duplicate = true;
  
  while($duplicate){
    $suit = rand(1, 4);
    $rank = rand(1, 13);
    if($cardLocation[$rank][$suit] == "deck"){
        $cardLocation[$rank][$suit] = "player";
        $duplicate = false;
  
      }
    }
  }
  
  ?&gt;
  </code></pre>
  
  <p>I'm trying to figure out a way of storing each value of the for loop into an array and then printing it out. Have had a few ideas but all of them failed. Any help would be welcomed.</p>