PHP - 2 variables in 1 string -


$title = get_the_title();  echo ($field["field_name"] == "subject" ? "value=\"" .$title. "\"" : "") ? 

this code sets field value text contents of $title variable. have variable $refcode sit next title read like:

title [refcode]

i not sure how place new variable next title?

you might use sprintf better overview on string.

$title = get_the_title(); $recode = 123;  echo ($field['field_name'] == 'subject'   ? sprintf( ' value="%s" refcode="%d" ', $title, $recode )   : ''); 

you can add many placeholder (%s, %d) want – order of given parameters matter. further description see: http://php.net/function.sprintf.php


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -