My php code is:
<?php
class Markov {
protected $arr0;
protected $arr1;
protected $arr2;
public $n;
public $p00;
public $p01;
public $p02;
public $p10;
public $p11;
public $p12;
public $p20;
public $p21;
public $p22;
public function __construct($p)
{
$arr0=new SplFixedArray(3);
$arr1=new SplFixedArray(3);
$arr2=new SplFixedArray(3);
$this->n=$p;
for($i=0; $i<3; $i++)
{
$arr0[$i]=0;
$arr1[$i]=0;
$arr2[$i]=0;
}
}
public function calculate_constants($first,$last)
{
if($this->n>1)
{
for($j=0; $j<count($first); $j++)
{
if($first[$j]>=0 && $first[$j]<3)
{
if($last[$j]>=0 && $last[$j]<3)
{
$this->arr.$first[$j][$last[$j]]+=1;
}
}
}
}
else
{
for($k=0; $k<3; $k++)
{
$this->p0.$k=$this->arr0[$k]/($this->arr0[0]+$this->arr0[1]+$this->arr0[2]);
}
for($k=0; $k<3; $k++)
{
$this->p1.$k=$this->arr1[$k]/($this->arr1[0]+$this->arr1[1]+$this->arr1[2]);
}
for($k=0; $k<3; $k++)
{
$this->p2.$k=$this->arr2[$k]/($this->arr2[0]+$this->arr2[1]+$this->arr2[2]);
}
}
$this->n-=1;
}
public function display_constants()
{
echo $this->p00.'\n'.$this->p01.'\n'.$this->p02;
echo $this->p10.'\n'.$this->p11.'\n'.$this->p12;
echo $this->p20.'\n'.$this->p21.'\n'.$this->p22;
}
}
$m= new Markov(5);
$m->calculate_constants(array(0,1,2),array(1,2,1));
$m->display_constants();
?>
In this my variable values p00,p01 etc are not changing even though I have used it in functions to calculate their value. Please Help me to correct the code so that the required output can be obtained