title: PHP : Associative array indexing issue
body: <p>My problem is very specific. I'm a beginner php programmer and I'm having difficulty indexing the array datastructure in PHP. The program is reading from an input file (<code>input.txt</code>) and storing the result into an array with key same as the item. Although the <code>input.txt</code> files have numbers for convenience I have to store them as string ( My program needs integers of size greater than 32 bit). But when I try to index them as <code>$a["3"]</code> I get an error <code>Undefined offset: 3</code>. I <code>tried $a['3']</code>, <code>$a[3]</code> all with the same result. But curiously I am able to index last element in the array that is <code>$a["2"]</code> correctly! Please help. </p>
  
  <p>Here is the input text file :</p>
  
  <pre><code>3
  4
  5
  1
  2
  </code></pre>
  
  <p>Here is the code segment :</p>
  
  <pre><code>&lt;?php
      ignore_user_abort(true);
      set_time_limit(0);
      $temp=0;
      $a= array();
      $file= fopen("input.txt","r") or exit( "unable to open file");
      while(!feof($file)){
          $temp=fgets($file); 
          $a[$temp]=$temp;     
      }   
      fclose($file);
      echo "&lt;br&gt;The array is .. ";
      foreach ($a as $key =&gt; $item) {
          echo "&lt;br&gt; Key =&gt; item =",$key."=&gt;",$item ;
          echo "&lt;br&gt;Manual array test ",$a["3"]; // This line demonstrates the problem. 
      }
      echo "&lt;br&gt;Manual array test ",$a["2"]; // This one has no error! So basically only the last element is being indexed correctly
  
      //echo "&lt;br&gt; No of 2 sums is ",twoSum($a,4,6);
  ?&gt;
  </code></pre>