change
strpos($value,$words)!== false
to
preg_match('/\b'.$value.'\b/', $words)
strpos search everything. if you search abc123 on the database and it exist but if you also have the value of 1, 2, 3 stored in the database it will print the value that's why you have repeated value output.