Can PHP exclude the newline character when reading line by line?
<p>I want to read line by line but I do not want to deal with newline, I want it to be removed so I only end up with the content of the line.</p>

<p>So right now my function is:</p>

<pre><code>function getProductCount($path)
{
   $count = 0;

foreach (file($path) as $name) {
    if($name == "&lt;product&gt;\n")
    {
       $count = $count + 1;
    }
}
       return $count;
}
</code></pre>

<p>But ideally I would want to do:</p>

<pre><code>function getProductCount($path)
{
   $count = 0;

foreach (file($path) as $name) {
    if($name == "&lt;product&gt;")
    {
       $count = $count + 1;
    }
}
       return $count;
}
</code></pre>

<p>Is there a way to also remove carriage returns too?</p>

<p>Thanks</p>
