$string[0] = "abc fghijklmn "; $string[1] = " b d fgh jklmno"; # correct answer is: "jklmn", 5 chars long; # (next longest common substring is " fgh", # but you're not interested in that)