drisate Posted May 6, 2010 Share Posted May 6, 2010 Hey guys i have a string that looks like this -3--3--3--3--3--3--3--3--3--3--10--10--10--10--10--10--10--10--10--10--7--7--7--7--7--7--7--7--7--7--12--12--12--12--12--12--12--12--12--12--1--1--1--1--1--1--1--1--1--1--19--19- How can i remove the duplicates so it looks like -3--10--7--12--1--19- It needs to be fast because there will be a lot of strings to be checked Quote Link to comment https://forums.phpfreaks.com/topic/200891-remove-duplicate-in-string/ Share on other sites More sharing options...
RichardRotterdam Posted May 6, 2010 Share Posted May 6, 2010 these functions might help you array_unique explode implode preg_match Quote Link to comment https://forums.phpfreaks.com/topic/200891-remove-duplicate-in-string/#findComment-1054099 Share on other sites More sharing options...
drisate Posted May 6, 2010 Author Share Posted May 6, 2010 Thx this is what i did for future ref $list3 = implode("-" , array_unique(explode("-",$bouton[bouton]))); $ex = explode ('-', $list3); foreach($ex as $value){ if ($value){ $string .= "-$value-"; } } Quote Link to comment https://forums.phpfreaks.com/topic/200891-remove-duplicate-in-string/#findComment-1054111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.