I have a php file with multiple lines that are identical in all ways, except for the variable displayed in them. At the moment, there are 26 lines of code, but can be reduced to two if there's a way to repeat the static php and place the dynamic variables in their required place. I'm asking for a place I can find some documentation on the function I'm looking for, or for an example that can help me work this out.
Some sample code:
<div id="DynamicName" <?php if ( $Survival == "Online" )
{echo "class='span2 up'><div class=service><div class=name>Survival</div><h2 class=status></h2>";}
else {echo "class='span2 down'><div class=service><div class=name>Survival</div><h2 class=status></h2>";} ?></div>
<div id="DynamicName2" <?php if ( $DynamicName2 == "Online" )
{echo "class='span2 up'><div class=service><div class=name>DynamicName2</div><h2 class=status></h2>";}
else {echo "class='span2 down'><div class=service><div class=name>DynamicName2</div><h2 class=status></h2>";} ?></div>
This is not the full code, but is the required portion that needs to be repeated.
- - , .
برچسب:
نویسنده: استخدام کار