title: Undefined Index (Laravel)
body: <p>I'm bashing my head against my desk trying to figure out why this PHP code is causing this error: <code>Undefined index: arr</code>. I'm using Laravel, and this code works like gold outside of it, but inside Laravel, it's returning the undefined index error.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>function set_pilots_array($line_array)
  {
      $airports = $this-&gt;airports;
      $pilots = $this-&gt;pilots;
      foreach($airports as $airport)
      {
          if($airport == $line_array[11] || $airport == $line_array[13])
          {
              if($airport == $line_array[11])
              {
                  $deparr = "dep";
              }
              if($airport == $line_array[13])
              {
                  $deparr = "arr";
              }
              $this-&gt;pilots[$deparr][] = array($line_array[0], $line_array[11], $line_array[13], $line_array[7], $line_array[5], $line_array[6], $line_array[8]);
          }
      }
  }
  
  function get_pilots_count()
  {
      $count = count($this-&gt;pilots['dep']) + count($this-&gt;pilots['arr']);
      return $count;
  }
  </code></pre>
  
  <p>This sort of goes with my other question: <a href="https://stackoverflow.com/questions/12168543/grab-and-explode-data">Grab and Explode Data</a>  It's pulling the data from the data file using this code:</p>
  
  <pre><code>elseif($data_record[3] == "PILOT")
  {
      $code_obj-&gt;set_pilots_array($data_record);
  }
  </code></pre>
  
  <p>Which later does this:</p>
  
  <pre><code>$code_count = $code_obj-&gt;get_pilots_count();
  </code></pre>