title: PHP read a file into an array
body: <p>I have a file (Test.txt) with the following data: 1,0</p>
  
  <p>I am wanting to read the contents of this file into an array and then print the variables. Here is my current code:</p>
  
  <pre><code>    function readUserDetails($username) {
      $userDetails = explode(',', file($username.".txt"));
      print($userDetails[0].$userDetails[1]);
  }
  </code></pre>
  
  <p>If I call the readUserDetails function with the folowing parameters: "Test", I get the following errors:</p>
  
  <blockquote>
    <p>Notice: Array to string conversion in C:\Users\s13\Game\Game6\default.php on line 128
    Notice: Undefined offset: 1 in C:\Users\s13\Game\Game6\default.php on line 129
    Array </p>
  </blockquote>
  
  <p>Can I please have some help to get this working?</p>