I managed to get it working. Using Euclidean Formula. below is a VERY basic version. It works for ANY values entered into the $arr1 and $arr2.
For anyone who might want it....
<?php
$arr1 = array ( 8,
4,
6 );
$arr2 = array ( 10,
7,
5 );
$arrsquares = array ();
$arrroot = array ();
$arrsmallest = array ();
echo "- - array of squares - -<br>";
// calculate sum of two arrays when squared
for ($i = 0; $i < count($arr1); $i++){
$arrsquares[$i] = ($arr1[$i] - $arr2[$i]) * ($arr1[$i] - $arr2[$i]);
echo "$arrsquares[$i]<br>";
}
echo "- - array of roots - -";
// calculate the square root of the sums
for ($ii = 0; $ii < count($arrsquares); $ii++){
$arrroot[$ii] = sqrt($arrsquares[$ii]);
echo "<br> $arrroot[$ii]";
}
// output best case ie. smallest number and its location
$smallest = min($arrroot);
echo "<br> smallest number is: $smallest<br>";
$position = array_search($smallest, $arrroot);
echo "smallest number found at position: $position ";
?>