title: How to pass multiple variables in a URL and have each one replaced by a default value if not supplied
body: <p>In need of a little PHP help here.</p>
  
  <p>The following PHP code works perfectly to pass an affiliate ID on a given website where the user adds their affiliate ID to the end of the URL, otherwise the default is used (I have been using this successfully).</p>
  
  <p>Example: </p>
  
  <blockquote>
    <p>www.example.com (uses 'defaultid' from the PHP code)</p>
    
    <p>www.example.com/?id=test1 (uses the affiliate ID 'test1' supplied by
    the user)</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  /* DEFAULT SETTINGS */
  
  $DEFAULT_ID = "defaultid";
  
  /* Function to display ID value */
  
  function displayID($defaultValue) {
  
  global $_GET, $DEFAULT_ID;
  
  if (isset($_GET['id']) and strlen(trim($_GET['id']))) {
  
   echo $_GET['id'];
  
  } else if (strlen(trim($defaultValue))) {
  
   echo $defaultValue1;
  
  } else {
  
   echo $DEFAULT_ID;
  
  }
  
  }
  
  /* End of function to display ID value */
  
  ?&gt;
  </code></pre>
  
  <p>What I'd like to know is how to modify above code to work for 3 different affiliate IDs where there are 3 hyperlinks on a given web page for 3 different affiliate offers.</p>
  
  <p>Example:</p>
  
  <blockquote>
    <p>www.example.com  (uses 3 default IDs that I've defined in the code)
    www.example.com/?id1=test1 (uses default IDs 'defaultid2' and
    'defaultid3') www.example.com/?id1=test1&amp;id2=test2 (uses just the
    default ID 'defaultid3') 
    www.example.com/?id1=test1&amp;id2=test2&amp;id3=test3 (uses the 3 IDs
    supplied in the URL by the affiliate)</p>
  </blockquote>
  
  <p>Please note I am not PHP savvy, so a modification of the above code would be preferred (if possible), rather than a complete rewrite that I may not understand.</p>