Jump to content


Photo

prevention of duplication on an array


  • Please log in to reply
4 replies to this topic

#1 gabrielkolbe

gabrielkolbe
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 08 May 2006 - 03:08 PM

Hi, I would be grateful if someone can help me here, I am querying an table with several different suppliers in, how do I echo out an array without repeating the same supplier twice, does any one know of such an function??
I would be grateful.

Thanks
The Devil never lies..he just almost tell the truth

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 08 May 2006 - 03:14 PM

SELECT DISTINCT(supplier_name), other_field1, otherfield2 FROM tablexyz WHERE blah blah

Info: PHP Manual


#3 gabrielkolbe

gabrielkolbe
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 08 May 2006 - 03:24 PM

Hi, thanks for the answer, but it is not what I want, I don't want / need a SQL solution to the problem the solution must be a PHP solution.
The Devil never lies..he just almost tell the truth

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 08 May 2006 - 03:31 PM

That's the most efficient way to achieve your required results, so that's what I provided. You didn't specify.

array_unique will probably get you what you want, but I'm going to assume that's probably to simple for what you're after, so the only thing left is to copy used array values to a temp array and then use in_array to check that for "used" array values.

Info: PHP Manual


#5 gabrielkolbe

gabrielkolbe
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 08 May 2006 - 03:38 PM

thanks
The Devil never lies..he just almost tell the truth




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users