What are the potential pitfalls of using elseif statements in PHP to assign values to variables?

Using elseif statements to assign values to variables can lead to code that is hard to read and maintain, especially as the number of conditions increases. A better approach would be to use a switch statement, which is more concise and easier to understand when dealing with multiple conditions.

// Using a switch statement to assign values to a variable
$number = 2;

switch ($number) {
    case 1:
        $result = "One";
        break;
    case 2:
        $result = "Two";
        break;
    case 3:
        $result = "Three";
        break;
    default:
        $result = "Unknown";
}

echo $result;