How can categories be displayed in a dropdown selection box in PHP?

To display categories in a dropdown selection box in PHP, you can retrieve the categories from a database or an array and then loop through them to create the options for the dropdown. You can use HTML <select> and <option> tags to create the dropdown menu and populate it with the category options.

&lt;select name=&quot;category&quot;&gt;
&lt;?php
// Assuming $categories is an array of category names
$categories = array(&quot;Category 1&quot;, &quot;Category 2&quot;, &quot;Category 3&quot;);

foreach ($categories as $category) {
    echo &quot;&lt;option value=&#039;$category&#039;&gt;$category&lt;/option&gt;&quot;;
}
?&gt;
&lt;/select&gt;