Translating JS function to PHP
<p>I'm trying to "translate" an JS function into PHP equivalent.
For the following JS function:</p>

<pre><code>function dF(s,n)
{
n=parseInt(n);
var s1=unescape(s.substr(0,n)+s.substr(n+1,s.length-n-1));
var t='';
for(i=0;i&lt;s1.length;i++)
{
t+=String.fromCharCode(s1.charCodeAt(i)-s.substr(n,1));
}
return(unescape(t));
}
</code></pre>

<p>i did this in PHP:</p>

<pre><code>function dF( $s, $n ) {
    $n1 = intval( $n );
    $s1 = urldecode( substr( $s, 0, $n1 ) . substr( $s, $n1+1, strlen( $s)-$n1-1 ));
    $t = '';
    for( $i = 0; $i &lt; strlen($s1); $i++ ) {
        $t .= unichr(substr($s1, $i) - substr($s, $n1, 1));
    }
    return urldecode($t);
}

/**
 * Return unicode char by its code
 *
 * @param int $u
 * @return char
 */
function unichr($u) {
    return mb_convert_encoding('&amp;#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
</code></pre>

<p>And it fails somewhere around <code>urldecode()</code> I persume. What am I doing wrong?</p>

<p>--- More info ---</p>

<p>Result for the JS function, for example <code>dF('8%3Fn%3FAAl%3A%3Ej%3D%3C%3B%3A%3DA%3Ail%40llk%3Aj%3B8%38El%3B%40m','55');</code> would be <code>07f799d26b5432592ad8ddc2b306d38e</code></p>

<p>But I'm not getting this as a result. After fixes from first answer, 
<code>echo dF('8%3Fn%3FAAl%3A%3Ej%3D%3C%3B%3A%3DA%3Ail%40llk%3Aj%3B8%38El%3B%40m', '55')</code> is empty, blank, nothing printed.</p>
