How to use Token Replace only if the field has a value? So I've been using token replace for a while now with great success in my themes.  For instance I'm using it currently to show the real name of an author by using

&lt;?php print token_replace('[node:author:url]', array('node' =&gt; $node)); ?&gt;"&gt;


The issue is that I've recently added a byline field in my storys and not all stories have a byline.  I've added it normally by using 

&lt;?php print token_replace('[node:field_byline]', array('node' =&gt; $node)); ?&gt;


However when the field is empty it simply prints [node:field_byline] so I get stories like...

By: [node:field_byline]

Is there a way to check that the token field has something in it and only show that field if there's a value?  I'd like to just show nothing if there are now authors for the byline.  I tried using something like:

&lt;? !empty [node:field_byline] ?&gt;


but this hasnt worked.  Ideas?
You can use the 'clear' option of token_replace to clear any tokens it can't find a replacement for.

&lt;?php print token_replace('[node:author:url]', array('node' =&gt; $node), array('clear' =&gt; TRUE,); ?&gt;"&gt;


As documented here: https://api.drupal.org/api/drupal/includes%21token.inc/function/token_replace/7.x