-1

How do I go about getting all of the duplicate values in an array, and assigning an integer to each of them to make them unique. For example:

array(
    0 => 'Title',
    1 => 'Primary Contact: Name',
    2 => 'Primary Contact: Email',
    3 = > 'Title',
    4 = > 'Title'
);

My goal is to turn that into the following:

array(
    0 => 'Title - 1',
    1 => 'Primary Contact: Name',
    2 => 'Primary Contact: Email',
    3 = > 'Title - 2',
    4 = > 'Title - 3'
);
Kenny
  • 46
  • 5

1 Answers1

0

You could use a foreach to integrate through the array and use array_keys with the search option to check for the value in the array and update it.

http://php.net/manual/en/function.array-keys.php

Hybrid
  • 105
  • 2
  • 5