Error in code.
Posted: Tue Nov 11, 2008 2:16 pm
I'm shaking off some rust in my php code for some math homework.
I get this problem when i run the code.[/b]
in the following code
I'm using vim as my IDE, but I think my rust is overwhelming. Thanks for any help 
I get this problem when i run the code.
This error corresponds to this line:Parse error: syntax error, unexpected '[' in /home/clinton/test.php on line 30
Code: Select all
q[$i][x]=p[$i-1][x];in the following code
Code: Select all
<?
//Vectors
$p[0][x] = 0;
$p[0][y] = 0;
$p[1][x] = 1;
$p[1][y] = 2;
$p[2][x] = 2;
$p[2][y] = 2;
$p[3][x] = 3;
$p[3][y] = 0;
//knot vectors
$knot = array (0,0,0,0,1,1,1,1);
$j = 1;
$t_prime = 1/2;
//division
for ($i=0; $i == 4; $i++){
if ($i <= $j - 1){
$q[$i][x]=$p[$i][x];
$q[$i][y]=$p[$i][y];
}
else if ($i>= $j && $i<=$j+2){
$q[$i][x]=(1-(($t_prime - $knot[$i-2])/($knot[$i+1]-$knot[$i-2])))*$p[$i-1][x]+(($t_prime - $knot[$i-2])/($knot[$i+1]-$knot[$i-2]))*$p[$i][x];
$q[$i][y]=(1-(($t_prime - $knot[$i-2])/($knot[$i+1]-$knot[$i-2])))*$p[$i-1][y]+(($t_prime - $knot[$i-2])/($knot[$i+1]-$knot[$i-2]))*$p[$i][y];
}
else if($i>=$j+3){
q[$i][x]=p[$i-1][x];
q[$i][y]=p[$i-1][y];
}
else();
}
print_r($q);
?>