title: String showing wrong length after going through function
body: <p>I have the following function in my class.</p>
  
  <pre><code>public function checkPostcodeFormat($postcode) {
      if (strlen($postcode) === 7 &amp;&amp; substr($postcode, 5) !== " ") {
          return substr($postcode, 0, 4) . ' ' . substr($postcode, 4, 3);
      } elseif (strlen($postcode) === 6 &amp;&amp; substr($postcode, 4) !== " ") {
          return substr($postcode, 0, 3) . ' ' . substr($postcode, 3, 3);
      } else {
          return $postcode;
      }
  }
  </code></pre>
  
  <p>If the postcode is returned via the substr functions it's fine, but if it's returned in the else section a <code>var_dump()</code> shows it to be the wrong length.</p>
  
  <pre><code>var_dump($_POST["postcode"]);
  </code></pre>
  
  <p>shows</p>
  
  <pre><code>string(7) "ab1 1ab"
  </code></pre>
  
  <p>Whereas</p>
  
  <pre><code>var_dump($class-&gt;checkPostcodeFormat($_POST["postcode"]));
  </code></pre>
  
  <p>shows</p>
  
  <pre><code>string(8) "ab1 1ab"
  </code></pre>
  
  <p>What could be causing the string to grow in length, if it's just being returned through the function?</p>