How can conditional logic be implemented to disable certain <option></option> elements based on a specific value in PHP?

To disable certain <option></option> elements based on a specific value in PHP, you can use conditional logic within a loop that generates the options. Check the value against the condition and add the 'disabled' attribute to the <option> tag if the condition is met.

&lt;select&gt;
    &lt;?php
    $options = array(&quot;Option 1&quot;, &quot;Option 2&quot;, &quot;Option 3&quot;);
    $disabledValue = &quot;Option 2&quot;; // Value to disable
    
    foreach($options as $option) {
        if($option == $disabledValue) {
            echo &quot;&lt;option disabled&gt;$option&lt;/option&gt;&quot;;
        } else {
            echo &quot;&lt;option&gt;$option&lt;/option&gt;&quot;;
        }
    }
    ?&gt;
&lt;/select&gt;