hy all, how to get previous value and check different between recently value and previous values in loop < 0.5?
if different value < 0.5 get it's array
please help me
define('DIV', 0.5);
function iteration($data, $data2)
{
$m1=$m2=$data;
$m3=multiply($m1,$m2);
echo "iteration 1:\n";
print_r($m3);
$temp_m3 = $m3;
for ($i=0;$i<count($temp_m3);$i++)
{
for ($j=0;$j<count($temp_m3[$i]);$j++)
{
if (isset($data2[$i][$j])){
$aR[] = (($temp_m3[$i][0]*$data2[$i][$j])+($temp_m3[$i][1]*$data2[$i][$j])+($temp_m3[$i][2]*$data2[$i][$j]));
}
}
}
print_r($aR);
echo $max = max($aR)."<br/>";
for($a=0; $a<count($aR);$a++){
$bg_max[] = $max/$aR[$a];
}
print_r($bg_max);
$m1=$m2=$m3;
for($c=2;$c<=7;$c++)
{
$m3=multiply($m1,$m2);
echo "iteration $c:\n";
print_r($m3);
$m1=$m3;
$aR2 = array();
for ($x=0;$x<count($m3);$x++)
{
for ($y=0;$y<count($m3[$x]);$y++)
{
if (isset($data2[$x][$y])){
echo "value aR=> ".$aR2[] = (($m3[$x][0]*$data2[$x][$y])+($m3[$x][1]*$data2[$x][$y])+($m3[$x][2]*$data2[$x][$y]))."<br/>";
}
}
}
echo $max2 = max($aR2);
$temp_max = array();
$bagi_max2 = array();
for($b=0; $b<count($aR2);$b++){
$bg_max2[] = $max2/$aR2[$b];
$temp_max[] = $max2/$aR2[$b];
}
print_r($bg_max2);
print_r($temp_max);
//DIV = 0.5
//how to check different value below?
if(????????????){
if((??????????????$bg_max2 - $bg_max< DIV){
return $bg_max2;
}
}else{
if((??????????????????? = $bg_max2 - $temp_max < DIV)){
return $bg_max2;
}
}
}
}
echo "<pre>";
$result_iteration = iteration($data,$data2);
echo "</pre>";