What are the potential pitfalls of using switch-case statements for comparison operations in PHP?

Using switch-case statements for comparison operations in PHP can become cumbersome and hard to maintain as the number of cases increases. An alternative approach is to use associative arrays to map values to corresponding actions, making the code more concise and easier to manage.

// Using associative arrays for comparison operations
$operations = [
    'add' => function($a, $b) { return $a + $b; },
    'subtract' => function($a, $b) { return $a - $b; },
    'multiply' => function($a, $b) { return $a * $b; },
    'divide' => function($a, $b) { return $a / $b; },
];

$operation = 'add';
$result = $operations[$operation](10, 5);
echo $result; // Output: 15