php - Condensing Code for GET Variables That Return The Same Values -


i'm going placing identical content different url strings, want condense code somehow. heres code

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"; } 

i tried this, no luck:

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

how condense code don't repeat same thing on , over?

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

i think should helps.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -