开发者

Adding content to variable

开发者 https://www.devze.com 2023-03-01 02:38 出处:网络
sorry I don\'t know the exact term for this. I\'ld like to add content to \"mymeta\" from the loops and echos.

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($finalArra开发者_如何学Goy['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.


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'] . " | " ;
0

精彩评论

暂无评论...
验证码 换一张
取 消