PHP - string from csv reporting more characters
<p>So, I'm making this easy register check page, where a user can enter an ID, and get the results matching that ID from a CSV file.</p>

<p>Problem I'm having, is that for some reason I can't get a good match. Or, it matches every single line.</p>

<p>var_dump on the two comparing strings gives me this:</p>

<pre><code>string(7) "AKM" string(3) "AKM"
</code></pre>

<p>AKM is the userID in this example. I've tried utf8 encoding and tried searching eeverywhere. Just cant figure out why I do not get a match, and why var_dump reports AKM to be 7 characters.</p>

<p>Any idea?</p>

<p>Code below:</p>

<pre><code>$file = 'report/report.csv';
$startRow = 6;
$hms = $_GET["hms"];

$csv = array_map(function($v){return str_getcsv($v, "\t");}, file($file));
$csv = array_slice($csv, 6);

foreach($csv as $row){
if (strpos($row,$hms) !== false) {
    $start = strpos($row[1], '(') - 2;
    $end = strlen($row[1]) - strpos($row[1], ')');

    $userID = substr($row[1],0,$start);
    $userName = substr($row[1],$start+3,-2);

    if($row[3] == "true"){
        $passed = "Bestått (".$row[4].")";
    }else{
        $passed = "Ikke bestått";
    }

    $result = [
        "id" =&gt; $userID,
        "name" =&gt; $userName,
        "passed" =&gt; $passed, 
        "datePassed" =&gt; $row[7],
        "timeSpent" =&gt; $row[6],
    ];

    var_dump($result);
}
}
</code></pre>

<p>This is how the CSV looks like:</p>

<blockquote>
  <p>response</p>
  
  <p>data</p>
  
  <p>identity_uid  identity_caption    completion  passed  result  attempts    time    last_access
  U_5A69E39671310F44A2333C9206DAD20C  xxx (Name)  100.0   true    82.6    3   00:57:09    2016/01/04 10:28:54
  U_DF5A47B8E1A6E247AA338F571A8F63B1  yyy (Name)  5.0 false   0.0 3   00:04:48    2016/01/15 07:26:05</p>
</blockquote>

<p>EDIT: This is the hidden characters I found now:</p>

<pre><code>'' . "\0" . 'A' . "\0" . 'K' . "\0" . 'M' . "\0" . ''
</code></pre>