在PHP中应用欧几里德距离公式

时间:2014-02-20 11:54:02

标签: php

这是我对欧几里德方程的公式实现。

    $i = 0;
    $min = 0;

    while ($row = @mysqli_fetch_array($result))

    {

        $pcount = $row['pcount'];

        $ncount = $row['ncount'];

        echo "pcount is $pcount<br/>";

        echo "ncount is $ncount<br/></br>";
        $a[$i] = $pcoutn ;
        $b[$i] = $pcoutn ;
        while ($row = @mysqli_fetch_array($result))

        {

            $a[$j] =    $row['pcount']; 
            $b[$j] =    $row['ncount'];
            $diff = sqrt(($a[$i] - $a[$j])^2 + ($b[$i] - $b[$j])^2 )
            $j= $j + 1;
            echo "$diff <br>";
        }               
        $i = $i + 1;        


    }

什么是语法错误?

错误是:Parse error: syntax error, unexpected '$j' (T_VARIABLE)

1 个答案:

答案 0 :(得分:1)

您已在线

跳过;
$diff = sqrt(($a[$i] - $a[$j])^2 + ($b[$i] - $b[$j])^2 )

使用

$diff = sqrt(($a[$i] - $a[$j])^2 + ($b[$i] - $b[$j])^2 );