PHP: A simple function to remove duplicate word in a string

PHP: A simple function to remove duplicate word in a string

$text ='one one, two three, two'; 
$result_text = preg_replace("/\b(\w+)\s+\\1\b/i", "$1", $text); 
echo "Result Text: ".$result_text;