I would like to have a variable $output inside while loop containing some html and a if statement which will give class ".time_active" only to the first while loop result. I'm not able to find a way to embed if statement properly any help would be much appreciated.
$count= 0;
while($start_time < $end_time){
$count++;
$output = "<label>
<input type='radio' class='if($count == 1) {echo 'time_active';}' id='id_slot' name='time'>
<span class='display'>span tag</span>
</label>";
}
echo $output;
source https://stackoverflow.com/questions/69366552/how-to-assign-a-variable-to-a-html-code-including-an-if-statement-in-php
Comments
Post a Comment