Looking for duplicate in local text file
<p>please could someone help me with this duplicate checking function. I'm still quite fresh when it comes to PHP, so please excuse me, if this is a simple fix.</p>

<p>I'm storing a list of email addresses to a file called list.txt. Here is the content of the file (each on a new line):</p>

<pre><code>bob@foo.com
sam@bar.com
tracy@foobar.com
</code></pre>

<p>Now I have a function (not working) that should check if email is already in the list:</p>

<pre><code>function is_unique($email) {
   $list = file('list.txt');

   foreach($list as $item){
      if($email == $item){
          return false;
          die(); 
      }
   }
   return true;
}
</code></pre>

<p>When I call the function in this test, with an existing email address, it still returns true:</p>

<pre><code>if( is_unique('bob@foo.com') ) {
    echo "Email is unique";
} else {
    echo "Duplicate email";
}

// Returns true even though bob@foo.com is in the list
</code></pre>

<p>I appreciate anyone's input.</p>
