I have a long list of PHP switch statements that differ only in a substring, such as with strx, stry and strz as shown below:
switch ($block_name) {
case "strx_blk":
$list = &$GLOBALS['strx_list'];
$checked = $GLOBALS['strx_checked'];
break;
case "stry_blk":
$list = &$GLOBALS['stry_list'];
$checked = $GLOBALS['stry_checked'];
break;
case "strz_blk":
$list = &$GLOBALS['strz_list'];
$checked = $GLOBALS['strz_checked'];
break;
}
I would like to know if there a more compact way to express the same logic in PHP. There could be a large number of such repetitions hence the necessity for automation.