0

i have this:

<?php 
$values = $cfs->get('promoter'); 
if (!empty($values)) {
    echo $cfs->get_labels('promoter');  
    echo implode(', ', array_keys($values));
}
?>
<br />

which prints something like this:

PromoterPromoter1, Promoter2

when i'd like something like this:

Promoter: Promoter1, Promoter2

also, how could i include the <br />within the php, so if the field is blank, the line break is also excluded?

thanks.

3 Answers 3

2
<?php 
$values = $cfs->get('promoter'); 
if (!empty($values)) {
    echo $cfs->get_labels('promoter').": ";  
    echo implode(', ', array_keys($values))."<br />";
}
?>

Use PHP's concatenation operator - i.e. a period.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. i had initially done similar with improper syntax: echo $cfs->get_labels('promoter'.": ");
Ah, yeah. All that is doing is passing "promotor:" to get_labels. You get used to it ;)
1

You can simply append a string ": " to the end

echo $cfs->get_labels('promoter').": ";  

Comments

0
<?php 
$values = $cfs->get('promoter'); 
if (!empty($values)) {
    $word = "";
    $word .= $cfs->get_labels('promoter');
    $word .= ": ";
    $word .= implode(', ', array_keys($values));
    $word .= "<br />";
    echo $word;
}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.