Michael
Michael

Reputation: 327

Adding content to variable

sorry I don't know the exact term for this. I'ld like to add content to "mymeta" from the loops and echos. I tried this but it's not working:

     $mymeta = if (strlen($finalArray['Title']) > 0){
       echo $finalArray['Title'] . " | ";
    }   
    +
    else if (strlen($finalArray['Name']) > 0){
       echo $finalArray['Name'] . " | ";
    }   
    +
    else if (strlen($finalArray['Caption']) > 0){
       echo $finalArray['Caption'] . " | ";
    } 
+
echo $finalArray['Date'] . " | " ;

Thanks for tips.

Upvotes: 0

Views: 1402

Answers (1)

Chris Eberle
Chris Eberle

Reputation: 48765

I'm not entirely sure, but I think this is what you're after.

$mymeta = "";
if (strlen($finalArray['Title']) > 0) {
    $mymeta .= $finalArray['Title'] . " | ";
}
else if (strlen($finalArray['Name']) > 0) {
    $mymeta .= $finalArray['Name'] . " | ";
}
else if (strlen($finalArray['Caption']) > 0) {
    $mymeta .= $finalArray['Caption'] . " | ";
} 

$mymeta .= $finalArray['Date'] . " | " ;

Upvotes: 2

Related Questions