What are some best practices for converting an array with numeric keys into an array with string keys in PHP?

When converting an array with numeric keys into an array with string keys in PHP, one common approach is to iterate through the array and create a new array with the desired string keys. This can be achieved by using a foreach loop to iterate through the original array and assigning values to the new array with string keys. By doing this, you can easily transform the structure of the array while preserving the original values.

// Original array with numeric keys
$numericArray = [0 => 'apple', 1 => 'banana', 2 => 'cherry'];

// Convert numeric keys to string keys
$stringArray = [];
foreach ($numericArray as $key => $value) {
    $stringArray['key_' . $key] = $value;
}

// Output the new array with string keys
print_r($stringArray);