PHP accessing String vars as Array and changing value
<p>Is it ok to do this please?</p>

<pre><code>for($i=0;$i&lt;strlen($str);$i++)
{
    if(!in_array($str[$i],$arAllowedCharset)){$str[$i]='';}
}
return $str;
</code></pre>

<p>It works, but I am unsure if I am "allowed" to do that, i.e. <code>$str[$i]='';</code>.<br/>
Note: <code>$str</code> is a string variable, <code>$arAllowedCharset</code> is an array containing only alphanumerical characters and a dash.</p>

<p>I use that to format user-submitted URLs in a custom CMS.</p>

<p>Thank you.</p>
