I am trying to polish some code with the if(!empty)
function in PHP but I don't know how to apply this to multiple variables when they are not an array (as I had to do previously) so if I have:
$vFoo = $item[1];
$vSomeValue = $item[2];
$vAnother = $item[3];
Then I want to print the result only if there is a value. This works for one variable so you have:
if (!empty($vFoo)) {
$result .= "<li>$vFoo</li>";
}
I tried something along the lines of
if(!empty($vFoo,$vSomeValue,$vAnother) {
$result .= "<li>$vFoo</li>"
$result .= "<li>$vSomeValue</li>"
$result .= "<li>$vAnother</li>"
}
But of course, it doesn't work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…