Return 相同值的 GET 变量的压缩代码

Condensing Code for GET Variables That Return The Same Values

我将为不同的 URL 字符串放置相同的内容,因此我想以某种方式压缩代码。代码如下

if($_GET['name']=='1'){
    $section = "Box 1";
}
if($_GET['name']=='2'){
    $section = "Box 1";
}
if($_GET['name']=='3'){
    $section = "Box 1";
}
if($_GET['name']=='4'){
    $section = "Box 1";
}

我试过了,但没有成功:

if($_GET['name']=='1','2','3','4'){
    $section = "Box 1";
}

如何压缩代码,这样我就不会一遍又一遍地重复同样的事情?

if ( in_array($_GET['name'], array(1,2,3,4)) ) {
  $selection = 'Box 1';
}

我觉得应该有帮助。

$val = intval($_GET['name']);

if($val >= 1 && $val <= 4 ){
    $section = 'Box 1';
}