Adds one to each key of an array.
For example array(0 => 'foo') would be array(1 => 'foo').
array: The array to increment keys on.
array The array with incremented keys.
public static function arrayKeyPlus($array) {
$keys = array_keys($array);
// Sort the keys in reverse order so incrementing them doesn't overwrite any
// existing keys.
rsort($keys);
foreach ($keys as $key) {
$array[$key + 1] = $array[$key];
unset($array[$key]);
}
// Sort the keys back to ascending order.
ksort($array);
return $array;
}