title: Unable to find position of the first occurrence in a string
body: <p>I need to find position of the first character occurrence in a string that does not repeat. So far all I have my <code>$pos</code> outputs <code>0</code>.</p>
  
  <pre><code>&lt;?php
  $sentence = "some long string";
  $found = false;
  
  while(!$found &amp;&amp; $sentence!== ""){
    $c = $sentence[0];
    $count = substr_count($sentence,$c);
  
    if ($count == 1) $found = true;
    else $sentence = str_replace($c,"",$sentence);
  }
  $pos = strpos($sentence, $c);
  echo "$c: $pos";
  </code></pre>
  
  <p>It wil output <code>l:0</code>. What's up with that?</p>
  
  <p>I understand that <code>$pos = strpos($sentence, $c);</code> will not be the correct way to find position. Why Im confused is, when I echo $c its value is "l". So, I thought if i use its value in strpos it will give me the correct position. So to get help on how to extract this first non repeating character position, i thought I would ask at StackOverlow to point me to the right direction. No need to be d**ks, I just learning and I appreciate the help.</p>