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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

Change the color of an oval at click in Java AWT -