0

PHP : I want check the words contained in other words.

Example
1. A = "Samsung Galaxy Note5", B = "Samsung Galaxy Note 5"
or
2. C = "Iphone 6 16 GB", D = "Iphone 6"
or
3. E = "Samsung Galaxy Note 4", F = "Samsung Galaxy s6"

 The result must be : 
    1. A = B, TRUE
    2. C = D, TRUE
    3. E != F, FALSE

What should i do? Anyone can help me? thank you.

1 Answers1

0

something like this will work

$a = "Iphone 6 16 GB";
$b = "Iphone 6";

if ( stristr( str_replace(' ', '', $a), str_replace(' ', '', $b) ) !== false ) // use strstr for case senstivity
    echo 'match found';
else
    echo "no match";
manjeet
  • 1,497
  • 10
  • 15