Note that there are some explanatory texts on larger screens.

plurals
  1. POSpace Characters Getting Converted to Unknown Character
    text
    copied!<p>I've got a problem with a module that I am writing. What I have is an array of names, which has a particular format and can contain characters as well as spaces. The name can be of two formats:</p> <pre><code>$name[0] = "--&gt; Psychic Barrtier"; $name[1] =" Initial Presence"; </code></pre> <p>In my code, I take each line in the array, and use a preg_match statement to see if it matches these two patterns. So, I am basically looking for a line that starts with two dashes and '>' this, followed by a space. Or I am looking for a line that starts with 4 spaces. This is my preg_match statement:</p> <pre><code>while (preg_match('/^(--&gt; |--&amp;amp;gt; |--&amp;gt; | {4}|&amp;#160;&amp;#160;&amp;#160; |Â+)(.+)$/', $name[$i], $capturedname)) </code></pre> <p>The problem is, both types of names are passing the preg_match statement, but when I encounter a name that starts with just the 4 spaces, the captured data in the variable $capturedname doesn't match up. Basically, what I'm capturing in $caputredname[0] is the whole thing, then $capturedname[1] would be just the spaces, and $capturedname[2] would be just the name. This is what I get instead:</p> <p>$capturedname[0]=" Evil Presence" $capturedname[1] = "�" $capturedname[2] = "� Evil Presence"</p> <p>Array 1 plus 2 should equal Array 0, but that's not the case here. The spaces are getting converted to some diamond with a question mark character and $capturedname[2] has the spaces again, it just doesn't add up. Any sort of help would be greatly appreciated. It's been bugging me for 3 days now. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload