We help IT Professionals succeed at work.

Create Unique Array Based on Array Keys in File

deharvy
deharvy asked
on
Medium Priority
240 Views
Last Modified: 2012-05-11
I have data in a file that I use 'explode' get the keys/values.

1=apple,2=lettuce
3=rice,4=juice
1=orange,5=yogurt

I will need to loop through each line to get a unique list of the array keys.

how do I write the foreach rule in order to put the unique list of keys in one array?

thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you.
Most Valuable Expert 2011
Author of the Year 2014

Commented:
Let's try to be clear on the terminology.  Are the numbers the "keys" here?  So that if you got unique keys you would have 1,2,3,4,5?  Would you care about apple vs orange (they both have the same key)?  Give us a little more to go on here, because the question looks very theoretical (even academic) and I have a feeling that there are practical matters that might influence the data structure.  What I am looking at here looks to me like it would be better suited to be XML, instead of a string of number=fruit pairs.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.