How to remove duplicates from string in PHP

1 Answer

0 votes
$s = "PHP general-purpose scripting PHP scripting language scripting PHP"; 

$s = implode(' ', array_unique(explode(' ', $s)));

echo $s;





/*
run:

PHP general-purpose scripting language

*/

 



answered Jun 26, 2021 by avibootz

Related questions

3 answers 158 views
1 answer 251 views
2 answers 136 views
136 views asked Jun 30, 2022 by avibootz
2 answers 152 views
1 answer 156 views
156 views asked Feb 9, 2024 by avibootz
...