Announcement

Collapse
No announcement yet.

How do you remove duplicates from a comma delimited string?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dwh
    replied
    Thanks!

    Leave a comment:


  • pwr_sneak
    replied
    Originally posted by dwh
    I have 3 comma delimeted strings:

    a=1,5,8,34
    b=4,7,9,34
    c=1,3,4,8,45

    How do I get the following result:

    d=1,3,4,5,7,8,9,34

    ?

    Thanks.
    - make 3 new arrays (explode() the strings)
    - array_unique() the 3 arrays
    - build string from this array (implode())
    Code:
    $d=implode(",",array_unique(explode(",",$a),explode(",",$b),explode(",",$c)));

    Leave a comment:


  • dwh
    started a topic How do you remove duplicates from a comma delimited string?

    How do you remove duplicates from a comma delimited string?

    I have 3 comma delimeted strings:

    a=1,5,8,34
    b=4,7,9,34
    c=1,3,4,8,45

    How do I get the following result:

    d=1,3,4,5,7,8,9,34

    ?

    Thanks.

Related Topics

Collapse

Working...
X