Converting JavaScript code to PHP
<p>I need help converting this code to PHP.  </p>

<pre><code>var formula = [10,6.7,3.4];  
var user1 = [1,0,2,1,1,0,2,2,2,2];  
var user2 = [2,1,2,0,1,2,2,2,0,0];  
var result = 0;  
calculate();  
function calculate(){  
    for(var i=0; i&lt;user1.length; i++){  
        result +=formula[Math.abs(user1[i]-user2[i])]  
    }
}  
alert(result);
</code></pre>

<p>PHP code:  </p>

<pre><code>&lt;?php     
$formula = array(10,6.7,3.4);  
$user1 = array(1,0,2,1,1,0,2,2,2,2);  
$user2 = array(2,1,2,0,1,2,2,2,0,0);  
$result = 0;  
function calculate(){  
    for($i=0, $size = count($user1); $i&lt;$size; $i++){  
        $result += $formula(abs($user1[$i]-$user2[$i]));  
    }
}
calculate();  
echo $result;  
?&gt;
</code></pre>

<p>PHP code does not work. Help me please.</p>
