The character intersection method currently has two strings
"A B C"
"D e f"
I have written a method to determine whether there is an intersection of the total characters of a string. I think it is a bit complicated. I want to convert the character into an array for comparison. Is there a direct comparison function? Second, the characters are separated by spaces. if there is no space, is there any faster way to convert the string into an array ..
$ Str_a = "a B C ";
$ Str_ B = "D E F ";
$ R = array_intersect (explode ("", $ str_a), explode ("", $ str_ B ));
Echo! Empty ($ R )? "Intersection": "No intersection ";
Reply to discussion (solution)
Spaces are also characters. why not?
No space
$ Str_a = "ABC"; $ str_ B = "DEF"; echo (similar_text ($ str_a, $ str_ B )? 'You': 'none '). 'intersection '; // no intersection $ str_a = "ABC"; $ str_ B = "DEB"; echo (similar_text ($ str_a, $ str_ B )? 'You': 'none'). 'interse'; // intersection