title: Strange PHP Scandir or Split error with array
body: <p>First, please forgive me, I'm still very new to this and I'm a little tired right now.</p>
  
  <p>I'm at my wits end over this. I've written a little PHP code so that a site I'm working on can update it's newsletters quickly and easily. The goal is to show the first newsletter as an embedded pdf and then show all the rest as links below it, so all the person who writes the newsletters needs to do is place them in the folder and use the proper naming format.</p>
  
  <p>I'm using scandir to scan the directory and return all the files in descending order, which will give the most recent file first provided they are named correctly (YYYY/MM). It then splits that filename up and passes the month into a function that returns the actual name of the month, and plugs all of that into the html and generates the page.</p>
  
  <p>It works perfectly, except for one thing. <strong>One</strong> file won't show the month. You can see in the <a href="https://i.stack.imgur.com/ZlvCC.png" rel="nofollow noreferrer">screenshot</a> that the file from August 2014 won't show the month, and I simply cannot figure it out. (Sorry about the stuff on the bottom, I can't post more than two links because I don't have enough rep so I had to make all my images into one, disregard the bottom half)</p>
  
  <p>Here's the code for my main program (sorry about the formatting, I had to combine things because of these stupid restrictions)</p>
  
  <pre><code>//sort in descending order so the most recent date is first
  $newsletterarray=scandir("../docs/newsletter", SCANDIR_SORT_DESCENDING);
  
  //print_r($newsletterarray); //shows all the values             
  
  //Splits the selected newsletter array into another array, [1] will be the month which can be passed into month.php
  $month = split("_", $newsletterarray[0]);
  
  $filenameSplit = split("_", $newsletterarray[0]);
  //The most recent newsletter is embedded
  echo('&lt;p&gt;
      &lt;a href="../docs/newsletter/' . $newsletterarray[0] . '"&gt;&lt;h4 align="justify"&gt;' . getMonth($filenameSplit[1]) . ' ' . $filenameSplit[0] . ' Newsletter&lt;/h4&gt;&lt;/a&gt;
  &lt;/p&gt;                            
  &lt;p&gt;
      &lt;object width="50%" height="500px" data="../docs/newsletter/' . $newsletterarray[0] . '" type="application/pdf"&gt;&lt;/object&gt;
  &lt;/p&gt;&lt;br&gt; &lt;h4&gt;Older Newsletters&lt;/h4&gt;');
  
  //starts at 1 so it skips the most recent newsletter
  //increments until it reaches 3 less than max, otherwise it shows directory stuff   
  for( $i = 1; $i &lt;= (count($newsletterarray) - 3); $i++) {
      $filenameSplit = split("_", $newsletterarray[$i]);  
      echo('&lt;a href="../docs/newsletter/' . $newsletterarray[$i] . '"&gt;' . getMonth($filenameSplit[1]) . ' ' . $filenameSplit[0] . ' Newsletter&lt;/a&gt;&lt;br&gt;');
  } 
  
  function getMonth($nummonth) {
      switch ($nummonth) {
          case 01:
              return "January";
              break;
          case 02;
              return "February";
              break;
          case 03:
              return "March";
              break;
          case 04:
              return "April";
              break;
          case 05:
              return "May";
              break;
          case 06:
              return "June";
              break;
          case 07:
              return "July";
              break;
          case 08:
              return "August";
              break;
          case 09:
              return "September";
              break;
          case 10:
              return "October";
              break;
          case 11:
              return "November";
              break;
          case 12:
              return "December";
              break;
          default:
              return "";
              break;
      }
  }
  </code></pre>
  
  <p>In the screenshot you can see some of the troubleshooting I did. You can see that the split says that <a href="https://i.stack.imgur.com/ZlvCC.png" rel="nofollow noreferrer">1</a> should be the correct value for 08, but when I pass it into the getMonth function it doesn't work. You'll also see that passing in 08 works just fine, so the error doesn't seem to be in the getMonth function.
  In addition to this, I tried adding a file to the actual directory, which did not change the error at all, but the intended functionality did work. I also tried removing the problematic file and renaming another file to have the same name, but the same error occurred.</p>
  
  <p>I'm really hoping this is just a stupid error where I wrote something that's preventing this specific file from working, it's really causing me some grief. Thank you.</p>