function calc($s) {
// Your code here
$num = ‘‘;
for($i=0;$i<strlen($s);$i++)
{
$str = substr($s,$i,1);
$num .= ord($str);
}
$old_num = $num;
$new_num = str_replace("7","1",$num);
$old_sum = 0;
$new_sum = 0;
for($t=0;$t<strlen($old_num);$t++)
{
$sum_old = substr($old_num,$t,1);
$old_sum = $old_sum + intval($sum_old);
$sum_new = substr($new_num,$t,1);
$new_sum = $new_sum + intval($sum_new);
}
return $old_sum-$new_sum;
}