title: Removing array index reference when using json_encode()
body: <p>I have made a small application using jQuery's <code>datepicker</code>. I am setting unavailable dates to it from a JSON file which looks like this:</p>
  
  <pre><code>{ "dates": ["2013-12-11", "2013-12-10", "2013-12-07", "2013-12-04"] }
  </code></pre>
  
  <p>I would like to check if a date given is already in this list and remove it if so. My current code looks like this:</p>
  
  <pre><code>if (isset($_GET['date'])) //the date given
  {
      if ($_GET['roomType'] == 2)
      {
          $myFile = "bookedDates2.json";
          $date = $_GET['date'];
          if (file_exists($myFile))
          {
              $arr = json_decode(file_get_contents($myFile), true);
              if (!in_array($date, $arr['dates']))
              {
                  $arr['dates'][] = $_GET['date']; //adds the date into the file if it is not there already
              }
              else
              {
                  foreach ($arr['dates'] as $key =&gt; $value)
                  {
                      if (in_array($date, $arr['dates']))
                      {
                          unset($arr['dates'][$key]);
                          array_values($arr['dates']);
                      }
                  }
              }
          }
  
          $arr = json_encode($arr);
          file_put_contents($myFile, $arr);
      }
  }
  </code></pre>
  
  <p>My problem here is that after I encode the array again, it looks like this:</p>
  
  <pre><code>{ "dates": ["1":"2013-12-11", "2":"2013-12-10", "3":"2013-12-07", "4":"2013-12-04"] }
  </code></pre>
  
  <p>Is there a way to find the date match in the JSON file and remove it, without the keys appearing after the encode?</p>