title: Shortening if else for multiple $_GET variables
body: <p>I'm using Laravel for an API and trying to fetch multiple _GET variables a user would type.</p>
  
  <p>The code looks like this when all filters are used:</p>
  
  <pre><code> public function MUIntervalAPICall(Request $dte)
      {
        $date = $dte-&gt;dte;
        $element_language = $dte-&gt;language;
        $element_customer = $dte-&gt;customer;
        $element_contract = $dte-&gt;contract;
        $element_subcontract = $dte-&gt;subcontract;
        $element = $dte-&gt;element;
  
        //all filters
  
        if(isset($_GET['customer']) &amp;&amp; isset($_GET['language']) &amp;&amp; isset($_GET['contract']) &amp;&amp; isset($_GET['subcontract']) &amp;&amp; isset($_GET['element']))
        {
          $where = ['dte' =&gt; $date, 'element_language' =&gt; $element_language, 'element_customer' =&gt; $element_customer, 'element_contract' =&gt; $element_contract, 'element_subcontract' =&gt; $element_subcontract, 'element' =&gt; $element];
        }
  
        $mu_interval = MUInterval::select('element_customer', 'element_contract', 'element_subcontract', 'element_language', 'element_site', 'element', 'src_id', 'src_type_id', 'dte', 'intvl', 'val_src_id', 'exception_name', 'duration_seconds', 'duration_fte')
            -&gt;where($where) 
            -&gt;get()-&gt;toArray();
        function array_to_xml( $data, &amp;$xml_data ) {
            foreach( $data as $key =&gt; $value ) {
                if( is_array($value) ) {
                    $key = 'Exception';
                    $subnode = $xml_data-&gt;addChild($key);
                    array_to_xml($value, $subnode);
                } else {
                    $xml_data-&gt;addChild("$key",htmlspecialchars("$value"));
                }
             }
        }
        $xml_data = new SimpleXMLElement('&lt;?xml version="1.0"?&gt;&lt;muExceptions&gt;&lt;/muExceptions&gt;');
        array_to_xml($mu_interval,$xml_data);
        $result = $xml_data-&gt;asXML();
        return Response::make($result, '200')-&gt;header('Content-Type', 'text/xml');
      }
  </code></pre>
  
  <p>Now a user would want to filter it out only with few variables in place. e.g. date and customer, or language and contract only.
  I'm currently writing a long block of if-else statements to produce results (really long, to include all possibilities for six $_GET variables):</p>
  
  <pre><code>elseif(isset($_GET['subcontract']) &amp;&amp; isset($_GET['element']))
        {
          $where = ['dte' =&gt; $date, 'element' =&gt; $element, 'element_subcontract' =&gt; $element_subcontract];
        }
  </code></pre>
  
  <p>Is there a shorter method for such a long if-else statements?</p>