I have two foreach loops in my function, each use the $newlist data passed to it, the first foreach loop, retrieves only one item from the database. The second foreach loop should/ought to independently retrieve separate three news items, however that is not the case, as in the html page, it only shows the first item retrieved in the first foreach loop three times, instead of three different items. How can I avoid this to achieve what I want?
function getNewsHTMLStructureIsland($newslist = array())
{
$html = '';
if (empty($newslist))
return NULL;
$html .= '<div role="main" class="fluid flush split homepage">';
$html .= '<div class="lc flush lc-island">';
$html .= '<div class="l-two-col">';
$html .= '<div class="l-main-container">';
$html .= '<div class="l-main">';
//<!-- Begin: Channel Archive Page - Primary Island -->
$html .= '<div class="island plain-island">';
foreach (array_slice($newslist, 0, 1) as $newslistarticle) {
$html .= '<div class="plain-feature block block-inset">';
$html .= '<a href="'. site_url() .'news/'.$newslistarticle->slug.' " data-omni-sm="hp_featureddl">';
$html .= '<img class="thumb" data-aspect-ratio="500x369" height="369" width="500" alt="'.$newslistarticle->title.'" src="" />';
$html .= '<div class="block-title">';
$html .= '<h2>'.$newslistarticle->title.'</h2>';
$html .= '<div class="byline">by Alexia Tsotsis</div>';
$html .= '</div>';
$html .= '</a>';
$html .= '</div>';
}
$html .= '<ul class="plain-item-list">';
foreach (array_slice($newslist, 1, 3) as $newsarticle) {
//print_r($tweet);
$html .= '<li class="plain-item block block-small">';
$html .= '<a href="'. site_url() .'news/'.$newslistarticle->slug.' " data-omni-sm="hp_featureddl">';
$html .= '<img class="thumb" data-featured-thumb="1" height="90" width="145" alt="" src="" />';
$html .= '<div class="plain-title">';
$html .= '<h2 class="h-alt">'.$newslistarticle->title.'</h2>';
$html .= '<p class="byline">by Jordan Crook</p>';
$html .= '</div>';
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
////<!-- End: Channel Archive Page - Primary Island -->
return $html;
}
}