Shouldn't this be `if ($i === $j) {`?