Sort records by date inside Foreach Loop

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 28, 2018   (RSS)

By Djulia - March 28, 2018 - edited: March 28, 2018

Hi,

You can try this :

<?php array_multisort(array_column($mediaRecords, "date"), SORT_ASC, $mediaRecords); ?>
<?php foreach ($mediaRecords as $record): ?>
  <?php foreach ($record['media'] as $index => $upload): ?>
  <img src="<?php echo $upload['thumbUrlPath2'] ?>" alt="<?php echo htmlencode($record['title']) ?>" />
  <?php endforeach; ?>
<?php endforeach ?>

Djulia

By Zicky - March 28, 2018

That did the trick. : )

Thank you Djulia!