[wd_asp elements=’search’ ratio=’100%’ id=1]

Stop duplicates of one part of an array

15th January 2019

Php - Loops

php codehaven

Database was getting 1 array
a$ = (“12,13,14”, “45,46,47” , “21,21,22”);
I wanted to stop the duplicates of the last part so unique array would not work.
I wanted to get 21-22 NOT 21-21-22 for the last part.


// stop dupes of same jobid
$temp=[];
foreach (explode(",", $row['jobid']) as $x ) {
$temp[$x] = $x;
}
$jobid[] = implode(",", $temp);