How can a switch statement be used to handle different radiobutton values in PHP form processing?

When processing a form in PHP that includes radio buttons, you may need to handle different values based on which radio button is selected. One way to do this is by using a switch statement to check the value of the radio button and execute different code blocks accordingly. This allows for cleaner and more organized handling of the different scenarios.

// Assuming a form with radio buttons named 'option'
$selectedOption = $_POST['option'];

switch($selectedOption) {
    case 'option1':
        // Code to handle option 1
        break;
    case 'option2':
        // Code to handle option 2
        break;
    case 'option3':
        // Code to handle option 3
        break;
    default:
        // Code to handle default case
}