I'm having some troubles sorting events for my website in wordpress. I'm using custom fields to create events with a title, a description and a date. I put every events date in an array:
$datesEvenements = array();
array_push($datesEvenements,get_field('date'));
I then get the timestamp for each date:
foreach($datesEvenements as $value){
$timestamp = strtotime($value);
array_push($tsEvenements,$timestamp);
}
I then proceed to sort my timestamp by replacing the past event by 0 or an association of the event timestamp with the difference between that timestamp and the present one.
$arrEventDelta = array();
for($i=0;$i<count($tsEvenements);$i++){
$tsi = $tsEvenements[$i];
if($ts>$tsi){
array_push($arrEventDelta,0);
}
elseif($ts<=$tsi){
array_push($arrEventDelta,array('TimestampEvenements'=>$tsi,'DeltaEvenements'=>$deltaTs));
}
After that, I would like to order the array '$arrEventDelta' by the 'DeltaEvenements' value. Unfortunately, I'm a bit confused with all those arrays. I've tried the array_multisort function like so:
$DeltaEvents = array();
foreach($arrEventDelta as $key => $row){
$DeltaEvents[$key] = $row['DeltaEvents'];
}
array_multisort($DeltaEvents, SORT_ASC, $arrEventDelta);
But it doesn't work. Any tips on how I could fix this?
This is what is outputed from this,
Array ( [0] => 0 [1] => Array ( [TimestampEvenements] => 1394582400 [DeltaEvenements] => **31923** ) [2] => Array ( [TimestampEvenements] => 1394668800 [DeltaEvenements] => **118323** ) [3] => 0 [4] => 0 )
I need to order the highlighted numbers in increasing order.