What are some alternative approaches to filling selection lists in PHP, aside from using for loops?

When filling selection lists in PHP, an alternative approach to using for loops is to utilize array functions such as array_map or array_reduce. These functions can help simplify the code and make it more concise by applying a callback function to each element in an array or reducing an array to a single value.

// Using array_map to fill a selection list with options
$options = range(1, 5); // Generate an array of numbers from 1 to 5
$selectionList = array_map(function($option) {
    return "<option value='$option'>$option</option>";
}, $options);

// Output the selection list
echo "<select>";
echo implode("", $selectionList);
echo "</select>";