I have an array with products where i want to search for duplicate names and increment the duplicate values.
I tried to create an empty array and push all the title values key[0] to it, then i found how many duplicates i have for each value of key[0] with array_count_values.
This is my array;
$products=Array
(
[0] => Array
(
[0] => 'Intel I3',
[1] => 146,
[2] => 'intel-i3'
),
[1] => Array
(
[0] => 'Intel I3',
[1] => 146,
[2] => 'intel-i3'
),
[2] => Array
(
[0] => 'Intel I3',
[1] => 250,
[2] => 'intel-i3'
),
[3] => Array
(
[0] => 'AMD graphic',
[1] => 146,
[2] => 'amd-graphic'
)
);
I want this result with incrementing by 1.
How can i get this result ?
$products=Array
(
[0] => Array
(
[0] => 'Intel I3',
[1] => 146,
[2] => 'intel-i3'
),
[1] => Array
(
[0] => 'Intel I3_1',
[1] => 146,
[2] => 'intel-i3'
),
[2] => Array
(
[0] => 'Intel I3_2',
[1] => 250,
[2] => 'intel-i3'
),
[3] => Array
(
[0] => 'AMD graphic',
[1] => 146,
[2] => 'amd-graphic'
)
);
[0] => 'Intel I3_1',is the difference