I have checkboxes set up for Facilities at holiday houses
I have allowed the managers to add custom values on each house.
How do I then organise the displayed result to order alphabetically?
i.e.
Air-Con
BBQ
Beachfront
WiFi
Garage (added value)
to display as
Air-Con
BBQ
Beachfront
Garage (added value)
WiFi
Im currently using the following code:
<?php if( get_field('amenities_lifestyle') ): ?>
<?php
$items = get_field('amenities_lifestyle');
if ($items): ?>
<ul class="amenities">
<p><strong>Facilities</strong></p>
<?php foreach( $items as $item ): ?>
<li><?php echo $item['label']; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
Hey,
There is a php function called sort()
which is used to sort an array of values.
$cars = array("Volvo", "BMW", "Toyota");
sort($cars);
Might be of some use to you.
Thank you so much for the response. I wasn’t aware about this