Jump to content

Merge (or collect) the data in array elements


cb2004
 Share

Recommended Posts

I have a site that needs to show a slideshow of results. I have managed to create the array of pages and sort them accordingly, but I need to merge or collect the data in a particular $pages->find. Here is the current code:

<?php

$template = 'template=61';
$sort = 'sort=-int_01';
$results1 = $pages->find("$template, comboResult.name=Lottery1|Lottery3, limit=2, $sort");
$results2 = $pages->find("$template, comboResult.name=Lottery2, limit=2, $sort");
$results = PageArray([ $results1, $results2 ]);
$results->sort("-int_01");
foreach($results as $r):
	$content = $r->comboResult;

?>
<div class="results swiper-slide">
	<div>
		<h2><?= $content->name ?> - <?= $r->date_01 ?></h2>
		<?php

		$number = str_split($content->number);
		echo '<p class="numbers">';
		foreach($number as $digit)
			echo "<span>$digit</span>";
		echo "</p>";

		?>
	</div>
</div>
<?php endforeach; ?>

So, what I need to do is merge the results from $results2 and place them in a single slide. As the $content->name and $r->date_01 should be the same (there are 2 draws on the same day), a check on those would be ideal as well. Then the results numbers would be displayed and there would be 2 sets of numbers.

Any help would be massively appreciated, my brain is tired. It basically needs to show 3 slides, 1 with the results from Lottery1, 1 with the 2 results from Lottery2, and 1 with the results from Lottery3.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...