title: Undefined offset in custom codeigniter library, what am i doing wrong?
body: <p>I'll have a view php errors in my code, that causes two errors with both $time and $date array. Php says Message: Undefined offset: 1 and 2 for both $time and $date.</p>
  
  <p>So the keys after i've done explode(), are undefined? How and why is this exactly? And how do i solve this issue? The array display results from the database which i can see when using print_r. </p>
  
  <pre><code> Array ( [0] =&gt; 05 [1] =&gt; 51 [2] =&gt; 00 ) 
   Array ( [0] =&gt; 1984 [1] =&gt; 06 [2] =&gt; 23 )
  </code></pre>
  
  <p>I tried quite couple things, none seem to work. I don't remember i had this issue ever before... I'll almost start thinking that maybe the problem could have something to do with Codeigniter?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Sweph {
   
   public $julian_ut = null; 
   
   public $config = array();
   
   public $chart_id='';
   
   public $user_id='';
   
   public $chart_name='';
   
   public $chart_time='';
   
   public $chart_date='';
   
   public $chart_search='';
   
   public $chart_timezone='';
   
   public $chart_houses='';
   
   public $chart_longitude='';
   
   public $chart_latitude='';
   
   public $time = array();
   
   public $date = array();
   
   /***
    * Initialize chart details
    **/
   public function __construct($config=array()) {
  
    // Get instance 
    $this-&gt;CI =&amp; get_instance();  
    
    // Initializes and Loads Ephemeris files from Directory
    swe_set_ephe_path(FCPATH.'ephemeris');
   
    // Creates objects from config array
    foreach ($config as $property =&gt; $value)
                  {
                       $this-&gt;$property = $value;
                  } 
    
    // Create time and date array
    $time = explode(":", $this-&gt;chart_time);
    $date = explode("-", $this-&gt;chart_date);
    
    // Calculates Julian day 
    $this-&gt;julian_ut = swe_julday(intval($date[0]), $date[1], $date[2], ($time[0] + $time[1] / 60 + $time[2] / 3600) , SE_GREG_CAL); 
    
          }
  
   /***
    * Return time/day in julian day number
    **/ 
   public function get_julian_ut() {
    return $this-&gt;julian_ut;
   }
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>** Errors **</p>
  
  <p>A PHP Error was encountered</p>
  
  <p>Severity: Notice</p>
  
  <p>Message: Undefined offset: 1</p>
  
  <p>Filename: libraries/Sweph.php</p>
  
  <p>Line Number: 61</p>
  
  <p>A PHP Error was encountered</p>
  
  <p>Severity: Notice</p>
  
  <p>Message: Undefined offset: 2</p>
  
  <p>Filename: libraries/Sweph.php</p>
  
  <p>Line Number: 61</p>
  
  <p>A PHP Error was encountered</p>
  
  <p>Severity: Notice</p>
  
  <p>Message: Undefined offset: 1</p>
  
  <p>Filename: libraries/Sweph.php</p>
  
  <p>Line Number: 61</p>
  
  <p>A PHP Error was encountered</p>
  
  <p>Severity: Notice</p>
  
  <p>Message: Undefined offset: 2</p>
  
  <p>Filename: libraries/Sweph.php</p>
  
  <p>Line Number: 61</p>
  
  <p><strong>Update:</strong> Forgot to mention array has results from database and added errors.</p>