<?php
var_dump(isOrthogonal([1, 2], [2, -1]))."\n";
var_dump(isOrthogonal([3, -1], [7, 5]))."\n";
var_dump(isOrthogonal([1, 2, 0], [2, -1, 10]))."\n";
function isOrthogonal($arr1, $arr2) {
$prod = 0;
$count = count($arr1);
for ($i = 0; $i < $count; $i++) {
$prod += $arr1[$i]*$arr2[$i];
}
return $prod == 0? true:false;
}
/*
//JS solution:
function isOrthogonal(ar1, arr2){
let prod=0;
let count=arr1.length;
for (i=0; i<count; i++){
prod+=arr1[i]*arr2[i];
}
return prod==0? true; false;
}
*/