How can arrays be utilized in PHP to handle multiple user options more flexibly?

To handle multiple user options more flexibly in PHP, arrays can be utilized to store and manage the various options. By using arrays, you can easily add, remove, or modify options without needing to change the code structure. This makes the code more scalable and adaptable to different user preferences.

// Example of using an array to handle multiple user options flexibly
$userOptions = [
    'option1' => 'Option 1',
    'option2' => 'Option 2',
    'option3' => 'Option 3'
];

// Loop through the user options and display them
foreach ($userOptions as $key => $value) {
    echo $key . ': ' . $value . '<br>';
}