Created
February 28, 2017 19:09
-
-
Save moff/c6f84071b7a6996879241dff0e90fa8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$arr = [ | |
"hello world world", | |
"hello world world world", | |
"hello world world world world", | |
"hello hello world", | |
"hello hello hello hello world" | |
]; | |
foreach ($arr as $str) { | |
echo preg_replace('/(\w{2,})(?=.*?\\1)\W*/', '',$str) . PHP_EOL; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment