The character intersection method currently has two strings: "A & nbsp; B & nbsp; C" "D & nbsp; E & nbsp; F" to determine whether the total character of A string has an intersection, I wrote a method myself and thought it was a bit complicated. I converted 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. Character intersection method
There are currently 2 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 ";
------ 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