PHP Loop Over ONLY Different Arrays

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-05-21T01:32:01Z Indexed on 2010/05/21 1:40 UTC
Read the original article Hit count: 360

Filed under:

Hello,

I have a single array with several of the same values. And I only want to loop over DIFFERENT values. How could I go about doing this?

Example

166-01 001;09;UO;
166-01 001;09;UO;
166-01 001;09;UO;
166-01 001;09;UO;
166-01 001;09;UO;
166-01 001;09;UO;
166-01 001;09;UO;_86
166-01 001;09;UO;_86
166-01 001;09;UO;_86
166-01 001;09;UO;_86
166-01 001;09;UO;_86
166-01 001;09;UO;_86_97
166-01 001;09;UO;_86_97
166-01 001;09;UO;_86_97
166-01 001;09;UO;_86_97_108
166-01 001;09;UO;_86_97_108
166-01 001;09;UO;_86_97_108_119
166-01 001;09;UO;_86_97_108_119

I have that in a single array, but I only want to loop for the different ones. So it would loop once for nothing, then once for _86, then once for _86_97, then once for _86_97_108, and then once for _86-97_108_119. So only loop for different key values,

or would there be a way to count the number of different keys?

© Stack Overflow or respective owner

Related posts about php