I want to offer a discount based on early booking but not sure how to get the discount that applies based on the current date.
I have seen some usort examples but not very familiar to me.
I want to keep using DateTime objects (not timestamps).
[php]
$today = new DateTime();
$data[‘earlybooking’] = array(
array(‘percentage’ => ‘25’, ‘beforedate’ => ‘10-12-2016’ ),
array(‘percentage’ => ‘15’, ‘beforedate’ => ‘31-03-2017’ ),
array(‘percentage’ => ‘10’, ‘beforedate’ => ‘30-04-2017’ ),
array(‘percentage’ => ‘20’, ‘beforedate’ => ‘31-01-2017’ )
);
// foreach ? Or maybe usort?
// usort example: http://stackoverflow.com/questions/7127764/sort-array-of-objects-by-date-field
[/php]