My attempts at exercism.org
1<?php
2
3declare(strict_types=1);
4
5function distance(string $strandA, string $strandB): int
6{
7 if (strlen($strandA) != strlen($strandB)) {
8 throw new InvalidArgumentException("strands must be of equal length");
9 }
10
11 $distance = 0;
12
13 for ($i = 0; $i < strlen($strandA); $i++) {
14 if ($strandA[$i] != $strandB[$i]) {
15 $distance++;
16 }
17 }
18
19 return $distance;
20}