Forum Moderators: coopster
100
101
102
103
103
104
105
105
105
I want to have a 1 before each of the number....but when there is a duplicate number I want it to count up. Such as:
1100
1101
1102
1103
2103
1104
1105
2105
3105
I was trying to use a $row++ but I don't know how to determine when to count up or not.
If anyone has some incite on this, thanks in advance.
$data[100] = 1;
$data[101] = 1;
$data[102] = 1;
then you can create another array to copy the keys into with the 1 appended. But before you add it to the array you can do a array_key_exists to see if you need to count up or not.
$original_array;
$new_array;
foreach ($original_array as $key=>$value)
{
$newkey = '1' . $key;
if (array_key_exists($newkey, $new_array)
{
$newkey++;
}
$new_array[$newkey] = 1;
}
}