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'] . " | " ;
精彩评论