work_it_work Posted September 21, 2009 Share Posted September 21, 2009 how can i remove duplicate entries from an array? let's say i have this array $array = array(1,2,3,4,5,5,5,6,7,2,4,5); how can i remove the duplicates ?? any idea ? Link to comment https://forums.phpfreaks.com/topic/174942-solved-duplicate-entries-in-array/ Share on other sites More sharing options...
Garethp Posted September 21, 2009 Share Posted September 21, 2009 http://au2.php.net/array_unique Link to comment https://forums.phpfreaks.com/topic/174942-solved-duplicate-entries-in-array/#findComment-921972 Share on other sites More sharing options...
redarrow Posted September 21, 2009 Share Posted September 21, 2009 quick example. <?php $array=array(1,2,3,4,5,5,5,6,7,2,4,5); $ansaw=array_unique($array); print_r($ansaw); ?> Link to comment https://forums.phpfreaks.com/topic/174942-solved-duplicate-entries-in-array/#findComment-921975 Share on other sites More sharing options...
work_it_work Posted September 21, 2009 Author Share Posted September 21, 2009 thank you thank you thank you!!!! it worked, and it worked fine.... this arrays are magic if u know how to use them this time prevented to insert duplicate entries in database fields $gg = implode(",", $_POST['opt']); if ($gg[0] == ",") $gg= substr($gg, 1); $tt = array($gg); $ttu = array_unique($tt); $ggtt = implode(",", $ttu); $sql_insert_item = $this->query("UPDATE " . DB_PREFIX . "users_details SET a='" . $ggtt . "' thanks redarrow!!! Link to comment https://forums.phpfreaks.com/topic/174942-solved-duplicate-entries-in-array/#findComment-921987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.