title: How do I get a property value from an object in a foreach loop?
body: <p>I iterate through an array(using a foreach loop) that contains two 'High Season' objects - the two objects have an id, start date and end date. I get the high season start date via getter and assign it to a variable with intentions of incrementing the month when I loop through the date difference of the high season's start date and end date. When I loop through the date difference, the Booking start date and end date are compared against the variable I have been incrementing by month, and then the variable "containing" the date is incremented by one month.</p>
  
  <p>Does this variable contain a reference to the array's high season object's start date property? when I dump the high seasons array the start date has changed to the same date as the variable that has been incremented by one month. How do I get the value of the high season start date property and not the reference of the array object's start date? </p>
  
  <p>I am using PHP 5.5.30.</p>
  
  <pre><code>foreach ($highseasons as $highseason) {
      $HSDate = $highseason-&gt;getStartDate();
      $diff = date_diff($highseason-&gt;getStartDate(), $highseason-&gt;getEndDate());
  
      $months = (int)$diff-&gt;format('%m');
      $SDBool = false;
      $EDBool = false;
  
      // loop through the date difference
      for ($i = 0; $i &lt;= $months; $i++) {
          var_dump($highseasons);
          $HSMonth = $HSDate-&gt;format('m');
          $BookingStartingMonth = $value-&gt;getStartDate()-&gt;format('m');
          $BookingEndingMonth = $value-&gt;getEndDate()-&gt;format('m');
  
          if ($HSMonth == $BookingStartingMonth) {
              $SDBool = true;
          }
  
          if ($HSMonth == $BookingEndingMonth) {
              $EDBool = true;
          }
  
          // add one month onto the high season date
          $HSDate-&gt;add(new DateInterval('P1M'));
      }
  }
  </code></pre>