function compareAndPrintInCommons($newArray, $controlArray) { $matches = []; foreach ($newArray as $singleElement) { if (lookInArray($singleElement, $controlArray)) { array_push($matches, $singleElement); } } foreach ($matches as $matchedNames) { echo $matchedNames . " was a matched name." . PHP_EOL; } }
function compareArray($newArray, $controlArray) { $match = 0; $diff = 0; foreach ($newArray as $singleElement) { if (lookInArray($singleElement, $controlArray)) { $match = $match + 1; } else { $diff = $diff + 1; } } return "These arrays have {$match} values in common and {$diff} that didn't match between the two arrays" . PHP_EOL; }