title: Hidden whitespace char causing preg_match to return false
body: <p>I have a strange problem and I apologise if the title does not make much sense as I cant seem to word it right.</p>
  
  <p>Basically I am trying to check if a certain string is only numbers, for this I am using regluar expressions</p>
  
  <pre><code>preg_match("/^[0-9]+$/", $ordernumber[1]);
  </code></pre>
  
  <p>this is where it gets hard to explain from debugging I have learned that <code>$ordernumber[1]</code> which should be <code>"41720"</code> when <code>var dumped $ordernumber[1]</code> has a string length of <em>6</em> when there is only <em>5 numerical digits</em> in there.</p>
  
  <p>Which leads me to believe there is a whitespace character in that string which is not accounted for in the regex.</p>
  
  <p><strong>How do I find out which whitespace/special character is in the string?</strong> </p>
  
  <p><strong>attached is a picture of the dump along with the result of the preg match which is 0/false.</strong> </p>
  
  <p>Note the string length</p>
  
  <p>Thank you for reading.</p>
  
  <p>Just figured out If I use <code>preg_match("/^[0-9]+$\D/", $ordernumber[1]);</code> \D(non-digit)then it does return true, which solves my issue, would still like to know what character it is though, if anyone knows how to find out.</p>
  
  <p>Answer below which will trim whitespace characters from the beginning and end of a string, would actually do what I wanted.</p>
  
  <p><img src="https://i.stack.imgur.com/BZMOf.png" alt="enter image description here"></p>