I am trying to figure out how I can use the ternary operator in my array. I want to be able to check if the value matches then make that option "selected"
.
Here is my code:
<select id="time_out_1" name="data[<?= $id;?>][time_out]">
<?php
$miltimes = array("<option value=\"0000\">0000</option>","<option value=\"0030\">0030</option>", "<option value=\"0100\">0100</option>", "<option value=\"0130\">0130</option>", "<option value=\"0200\">0200</option>", "<option value=\"0230\">0230</option>",
"<option value=\"0300\">0300</option>", "<option value=\"0330\">0330</option>", "<option value=\"0400\">0400</option>", "<option value=\"0430\">0430</option>", "<option value=\"0500\">0500</option>", "<option value=\"0530\">0530</option>", "<option value=\"0600\">0600</option>", "<option value=\"0630\">0630</option>", "<option value=\"0700\">0700</option>", "<option value=\"0730\">0730</option>", "<option value=\"0800\">0800</option>", "<option value=\"0830\">0830</option>", "<option value=\"0900\">0900</option>", "<option value=\"0930\">0930</option>", "<option value=\"1000\">1000</option>", "<option value=\"1030\">1030</option>",
"<option value=\"1100\">1100</option>", "<option value=\"1130\">1130</option>", "<option value=\"1200\">1200</option>", "<option value=\"1230\">1230</option>", "<option value=\"1300\">1300</option>", "<option value=\"1330\">1330</option>", "<option value=\"1400\">1400</option>", "<option value=\"1430\">1430</option>", "<option value=\"1500\">1500</option>", "<option value=\"1530\">1530</option>", "<option value=\"1600\">1600</option>", "<option value=\"1630\">1630</option>", "<option value=\"1700\">1700</option>", "<option value=\"1730\">1730</option>", "<option value=\"1800\">1800</option>", "<option value=\"1830\">1830</option>", "<option value=\"1900\">1900</option>", "<option value=\"1930\">1930</option>", "<option value=\"2000\">2000</option>", "<option value=\"2030\">2030</option>", "<option value=\"2100\">2100</option>", "<option value=\"2130\">2130</option>", "<option value=\"2200\">2200</option>", "<option value=\"2230\">2230</option>", "<option value=\"2300\">2300</option>", "<option value=\"2330\">2330</option>");
foreach($miltimes as $miltime) { echo $miltime; }
echo '</select>';?>
I found this answer but I am not quite sure how to use it in my situation.
Using an If-else within an array
Thanks in advance for the help.