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 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 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-"; } } Link to comment https://forums.phpfreaks.com/topic/200891-remove-duplicate-in-string/#findComment-1054111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.