<?php $word1 = 'abcdefghijkl'; $word2 = 'acgikluuo'; $expected = 6; function countMatchingChars($word1, $word2) { $matching = 0; foreach(str_split($word1) as $char) { if(strpos($word2, $char) !== false) { $matching++; } } return $matching; } $matchingChars = countMatchingChars($word1, $word2); assert($matchingChars === $expected);
You have javascript disabled. You will not be able to edit any code.