Moin allerseits,
ich möchte bei Wertzuweisungen Teile konditional behandeln.
Konkretes Beispiel:
$html = '
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Vorname</th>
<th>Adresse</th>
<th>Aktion</th>
</tr>
</table>
';
Jetzt will ich Aktion abhängig von einer Bedingung einfügen, den Rest aber unabhängig davon.
Meine Idee war folgende Funktion:
function conditional($condition,$value)
{
return ($condition) ? $value : NULL;
}
Mit folgendem Aufruf:
$html = '
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Vorname</th>
<th>Adresse</th>'
.conditional(true,'<th>Aktion</th>').
'</tr>
</table>
';
Ist da so optimal, oder gibt es eine bessere Variante?
Grüße, JN
--
ie:{ fl:( br:^ va:| ls:[ fo:| rl:? n4:? ss:| de:] js:| ch:? sh:( mo:| zu:)
http://www.johny7.de
ie:{ fl:( br:^ va:| ls:[ fo:| rl:? n4:? ss:| de:] js:| ch:? sh:( mo:| zu:)
http://www.johny7.de