This line $text = preg_replace('/[\s\r\n\t]/', ' ', $text); replaces special characters with white spaces. How do I remove special characters without replacing them with white spaces.
Instead of preg_replace('/[\s\r\n\t]/', ' ', $text); use: preg_replace('/[\s\r\n\t]/', '', $text); I think that is what you meant....