开发者

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($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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜