3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name1 = 'The cat is red and wet'; $name2 = 'The cat is green and wet'; function stringDiff($string1, $string2) { $x = str_split($string1); $y = str_split($string2); $diff = array_diff($x, $y); foreach ($diff as $letter) { $string1 = str_replace($letter, '-', $string1); } return $string1; } var_dump(stringDiff($name1, $name2));

preferences:
54.15 ms | 402 KiB | 5 Q