<?php 

$inputs = [0,0]; 
$expectedOutput = 0;

array_push ($inputs, -1); //adding bias
$neuronWeights = [0.05, -0.02, 0.02];

$inputsLength = count($inputs);
$sum = 0;

for($i = 0; $i < $inputsLength; $i++){
	$sum += $inputs[$i] * $neuronWeights[$i];
}

//echo $sum;

if($sum > 0){
	$ouput = 1;
}
else {
	$output = 0;
}


if($output == $expectedOutput){
	echo "correct weights";
}
//fix the weights. 0.25 is n
elseif($output > $expectedOutput){	
	for($i = 0; $i < $neuronWeights; $i++){
		$neuronWeights[$i] = $neuronWeights[$i] - 0.25 * (1-0) * $inputs[$i];
	}
}
else {
	for($i = 0; $i < $neuronWeights; $i++){
		$neuronWeights[$i] = $neuronWeights[$i] - 0.25 * (0-1) * $inputs[$i];
	}
}