I have a dictionary array like below
$foo = array(
'key1' => 'value 1',
'key1' => 'value 2',
'key2' => 'value 3',
'key2' => 'value 4',
'key3' => 'value 5'
);
as you can see there are duplicate keys. All keys are strings. Array sits in a file and was created manually. It has close to a 1000 entries with potentially many duplicate keys.
How can I find out which keys are duplicates?
The result I want to get is a list of the keys that have duplicates:
key1, key2, ...
so I can go in the file and fix those keys to make them unique. Any format is fine, just so I know the names of those keys.
key3
has no duplicate so it's fine.
Any help would be greatly appreciated.
Thanks.
Most of you seem to be telling me the same thing :) I know I can't have multiple keys. The problem is that this is a dictionary array created manually in a flat file. The person who created it added the same keys multiple times. The problem is that key1
on one page has translation A
but on other page it should have translation B
, but since both values have the same key in my dictionary array they both display the same value.