title: Comparing two identical strings returns false in PHP
body: <p>I'm trying to compare two strings. When I echo them, they appear to be identical, yet when I compare them with the '==' operator, it returns false. For example, when running the code below on my database. It outputs things like &quot;APPARENTLY Apple does not equal Apple&quot;. What is the reason?</p>
  <pre><code>if ($this-&gt;data['list_text']) { // The user has entered into textarea
  
      $list = nl2br($this-&gt;data['list_text']);
  
      $list_array = explode('&lt;br /&gt;', $list);
  
      $ranking = 1;
      $company_array = $this-&gt;CompanyList-&gt;CompanyRanking-&gt;Company-&gt;find('list', null);
  
      // This is the comparison bit
      foreach ($list_array as $key =&gt; $value) {
          $companyId = null;
          foreach ($company_array as $key2 =&gt; $value2) {
              if ($value2 != $value) {
                  echo 'APPARENTLY ' . $value2 . ' does not equal ' . $value;
              } else {
                  $companyId = $key2;
                  break;
              }
          }
  
          $this-&gt;data['CompanyRanking'][$ranking]['ranking'] = $ranking;
          $this-&gt;data['CompanyRanking'][$ranking]['company_id'] = $companyId;
          $ranking++;
      }
  }
  </code></pre>