What is the best practice for assigning values based on user selection in a dropdown menu using PHP?

When a user selects an option from a dropdown menu, you may want to assign a corresponding value to a variable in PHP. One way to achieve this is by using a switch statement to check the selected option and assign the appropriate value to the variable.

<?php
// Assuming the dropdown menu has options with values 'option1', 'option2', 'option3'
$user_selection = $_POST['dropdown']; // Assuming the form method is POST

switch($user_selection) {
    case 'option1':
        $selected_value = 'Value 1';
        break;
    case 'option2':
        $selected_value = 'Value 2';
        break;
    case 'option3':
        $selected_value = 'Value 3';
        break;
    default:
        $selected_value = 'Default Value';
}

echo $selected_value;
?>