Sorry, I suppose I misunderstood your problem.
I don't beleive in silly questions! Sure it is possible.
First write your program to do the following:
1.) Before adding the new record check for existence of the record to be added. Or, in other words, write a boolean function like is_record() that will return true if the record already exists.
2.) If the record does already exist write an shuffle_records() function to shuffle the indices beginning with the record in question. Loop through each record starting with that record and apply an increment method... $i++.
3.) Then insert the new record.
Without more background information, this may not be the best method. But definitely one that will do the trick.
Suppose the following...
$foo[1] = 'lamp';
$foo[2] = 'pen';
$foo[3] = 'disk';
$foo[4] = 'yyy';
function is_record($needle, $haystack)
{
return array_key_exists($needle, $haystack);
}
function shuffle_records($key, $records)
{
// Assuming you're always going to have the records numbered
// without any gaps, this will work
for ($key; $key < count($records); $key++)
{
$new_records[$key + 1] = $records[$key];
}
return $new_records;
}
if (is_record(3, $foo))
{
$foo = shuffle_records(3, $foo);
$foo[3] = 'XXX';
}
else
{
$foo[3] = 'XXX';
}
hth,
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::