What are some potential pitfalls when trying to modify an array of column names in PHP for display purposes?

When trying to modify an array of column names in PHP for display purposes, a potential pitfall is accidentally modifying the original array instead of creating a new modified array. To solve this issue, you should create a new array to store the modified column names and leave the original array unchanged.

// Original array of column names
$originalColumns = ['first_name', 'last_name', 'email'];

// Modify column names for display purposes
$modifiedColumns = [];
foreach ($originalColumns as $column) {
    $modifiedColumns[] = ucfirst(str_replace('_', ' ', $column));
}

// Output modified column names
print_r($modifiedColumns);