I have a form with multiple inputs for one value which have similar names. something like this:
isset($_GET['name1'])
isset($_GET['name2'])
isset($_GET['name3'])
Always, either only one of them is true or none of them. And here is my code:
$name = '';
if( isset($_GET['name1']) ){
$name = $_GET['name1'];
} else if ( isset($_GET['name2']) ) {
$name = $_GET['name2'];
} else if ( isset($_GET['name3']) ) {
$name = $_GET['name3'];
}
echo $name;
My code works as well. But I guess I can do that without those conditions. Any idea how can I write that logic more clean?