I Found this post PHP: Limit foreach() statement? It talks about doing what I want to do but i'm unsure how to edit my code and or where to place it. Can anyone show me where to put the code / How to edit it to make it show only X Number of the array?
{~* Get Ads *~}
{~$ads2=array()~}
{~foreach $ads as $data~}
{~capture append="ads2"~}
{~if $data.code~}
<div>{~$data.code|decode~}</div><br />
{~else~}
<div><a rel="nofollow" href="{~$conf.path~}side/sideClick.php?spid={~$data.id~}" target="_blank">{~if $data.url~}<img src="{~$data.url~}" border="0" alt="{~$data.title~}" {~if $config->get('sideForce')~} width="120" height="60"{~/if~}>{~else~}{~$data.title~}{~/if~}</a></div>
{~/if~}
{~/capture~}
{~/foreach~}
{~* Advertise Here *~}
{~if !$config->get('sideNoFill') || $config->get('sideNoFill')=='2'~}
{~* Advertising Spots *~}
{~if $adsRows>=5 || $config->get('sideNoFill')=='2'~}
{~$rows=1~}
{~else~}
{~$rows=5-$adsRows~}
{~/if~}
{~* Advertising Text *~}
{~if $config->get('sideAds')=='image'~}
{~$adText="banner"~}
{~elseif $config->get('sideAds')=='text'~}
{~$adText="text link"~}
{~else~}
{~$adText="banner or text link"~}
{~/if~}
{~* Loop *~}
{~section loop=$rows name="sidePanel"~}
{~capture append="ads2"~}
<div><a href="{~$conf.path~}side/index.php">Your 120x60 {~$adText~} here, <br>As Low As 8 Cents Per Day!</a></div>
{~/capture~}
{~/section~}
{~/if~}
{~* Horizontal Ads *~}
{~if $horizontal>0~}
{~if count($ads2)~}
<table cellpadding="4" cellspacing="0" style="border:0px;width:100%;table-layout:fixed">
{~$i=1~}
{~foreach $ads2 as $data~}
{~if $i==1~}
<tr valign="top">
{~/if~}
<td>{~$data~}</td>
{~if $i==$horizontal~}
{~$i=1~}
</tr>
{~elseif $data@last~}
<td colspan="{~$horizontal-$i~}"></td>
</tr>
{~else~}
{~$i=$i+1~}
{~/if~}
{~if (++$i == 5) break;~}{~/if~}
{~/foreach~}
</table>
{~/if~}
{~* Vertical Ads *~}
{~else~}
{~foreach $ads2 as $data~}
<div>{~$data~}</div>
{~if !$data@last~}<br />{~/if~}
{~/foreach~}
{~/if~}
I Tried messing around with it to find where to put it but i just keep getting errors.
I am using the Vertical Ads Ver. (There shown one on top of each other.)
I want to Limit the Number of ads being show, as it is now it shows all of them, all of the time, each time coming up in a Random order. I want it to be the same except only show the First X number of them that are pulled and forget the rest tell next load. Since they are coming in random order they will all be shown, just not all at the same time.