What are the best practices for structuring and formatting data in a dropdown list in PHP to display multiple columns of information?

When displaying multiple columns of information in a dropdown list in PHP, it is best to use an HTML <select> element with <option> tags that contain the necessary data. Each <option> tag can be formatted to display multiple columns using HTML and CSS. To achieve this, you can concatenate the data from different columns into a single string and separate them with appropriate delimiters. This way, you can easily parse and display the data in the dropdown list.

&lt;select&gt;
    &lt;?php
    // Sample data with multiple columns
    $data = [
        [&#039;1&#039;, &#039;John Doe&#039;, &#039;john.doe@example.com&#039;],
        [&#039;2&#039;, &#039;Jane Smith&#039;, &#039;jane.smith@example.com&#039;],
        [&#039;3&#039;, &#039;Alice Johnson&#039;, &#039;alice.johnson@example.com&#039;]
    ];

    // Loop through the data and format it for the dropdown list
    foreach ($data as $row) {
        $optionText = $row[0] . &#039; - &#039; . $row[1] . &#039; (&#039; . $row[2] . &#039;)&#039;;
        echo &quot;&lt;option value=&#039;{$row[0]}&#039;&gt;{$optionText}&lt;/option&gt;&quot;;
    }
    ?&gt;
&lt;/select&gt;