title: Dynamically create vCard
body: <p>I was wondering what is the best way to create vCard. I don't need to store it on my server, just generate it when user wants to download it. The below code works, but it seems clumsy to me, is there any better way?</p>
  
  <pre><code>&lt;?php
  function raf_create_vcard(){
  $format_name = utf8_encode($name);
  $format_email = utf8_encode($email);
  $format_tel = utf8_encode($tel);
  $format_fax = utf8_encode($fax);
  $format_www = utf8_encode($www);
  $format_address = utf8_encode($address);
  
  return 'BEGIN%3AVCARD%0D%0AVERSION%3A4.0%0D%0AN%3A%3B'.$format_name.'%3B%3B%3B%0D%0AFN%3A'.$format_name.'%0D%0AEMAIL%3A'.$format_email.'%0D%0AORG%3A'.$format_name.'%0D%0ATEL%3A'.$format_tel.'%0D%0ATEL%3Btype%3DFAX%3A'.$format_fax.'%0D%0AURL%3Btype%3Dpref%3A'.$format_www.'%0D%0AADR%3A%3B'.$format_address.'%3B%3B%3B%3B%3BSpain%0D%0AEND%3AVCARD';   
  }
  ?&gt;
  </code></pre>
  
  <p>Generating link:</p>
  
  <pre><code>&lt;a href="data:text/plain;charset=UTF-8,&lt;?php echo raf_create_vcard(); ?&gt;" download="contact.vcf"&gt;Download&lt;/a&gt;
  </code></pre>