Building a link with l() and t() I'm trying to build this:

&lt;a href="/en/webform?edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]=NAME-OF-PET" class="btn btn-primary btn-xs"&gt;Adopt NAME-OF-PET&lt;/a&gt;


the code I'm using:

$adopt_me_link_male = l(t("Adopt !name",
 array('!name' =&gt; $node-&gt;field_pet_name['und'][0]['safe_value']), array('context' =&gt; 'Male pet name')), 'node/163', array('query' =&gt; array('edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]=' =&gt; $node-&gt;field_pet_name['und'][0]['safe_value'])), array('attributes' =&gt; array('class' =&gt; array('btn', 'btn-primary', 'btn-xs'),),) );


The above code generates the link but I have two problems:


the link looks like this:

Adopt NAME-OF-PET
there's no css class applied to the anchor


Why the classes are not applied and the link looks so messy?

Thank you!
There is a bug in your URL snippet (syntax error), so I'm writing the code. 

&lt;?php 
$adopt_me_link_male = l(
  t('Adopt @name', 
    array('@name' =&gt; $node-&gt;field_pet_name['und'][0]['safe_value']), //t() function replacements array
    array('context' =&gt; 'Male pet name') //t() function options array. Not necessary in this case though.
    ),
  'node/163', // l() function - URL
  array(
    'query' =&gt; array(
      'edit[submitted][nameofthepet_webform_fieldset][webform_nume_animal_comp]' =&gt; $node-&gt;field_pet_name['und'][0]['safe_value'],
    ),
    'attributes' =&gt; array(
      'class' =&gt; array('btn', 'btn-primary', 'btn-xs'),
    ),
  )
);

?&gt;


In this example, I changed !name to @name for the security (Read t() function documentation). Also, if you want to use HTML inside the anchor (say, an image), you have to pass 'html' =&gt; TRUE the last parameter array in the l() function (add it along with the attributes and query array keys).