Sort records by date inside Foreach Loop

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

By Mikey - March 26, 2018

I need to sort all my records inside of a foreach loop by date. I know this can be done using 'orderBy' => 'date ASC', but I can use that function in this scenario, and I need to sort the records by date inside, or just before the foreach loop. Anyone have any suggestions?

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



By Mikey - March 28, 2018

That did the trick. : )

Thank you Djulia!