I am creating a webpage for my newsletter archives. The archives are divided by year (currently there is only 1, but there could be many), then by topic, before listing each newsletter. There will always be exactly five topics, but the number of newsletters in each topic will vary.

I add the name of the newest newsletter in only one place - at the end of the array. I have a link to the most recent newsletter above the rest of the archives.

This code works fine, but the way that I am retrieving the most recent newsletter seems somewhat hacky

The newsletters are currently stored in my server as # segment year.

$newsletter = array(
        "Year 1" => array(
                "First Topic" => array(
                "Second Topic" => array(
                "Third Topic" => array(
                "Fourth Topic" => array(
                "Fifth Topic" => array(


$archive_design = "";

foreach($newsletter as $gilYear => $book){
    $archive_design .= "<div id=$gilYear class=year>
        <!--<h3> Year $gilYear </h3>-->
        <div class=year-content>";
    foreach($book as $book => $segment){
        $archive_design .= "<div id=$gilYear-$book class=column>
        foreach($segment as $segment){
            $link = "$i ".strtolower($segment)." ".$gilYear;
            $recent = $segment;
            $archive_design .= "<li>
                                <a href=\"http://example.org/newsletter/$link.pdf\" target='_blank'>$segment </a>
        $archive_design .= "</ul></div><!--end $gilYear-$book-->";
    $archive_design .=  "</div><!--end year-content -->
            </div><!--end $gilYear -->";
<html lang="en" >


<div id="header">
        <a href="http://example.org/newsletter/<?php echo $link; ?>.pdf" target=_blank> Current Issue - <?php echo $recent;?></a></br>

    <h3>Click on the segment to view, download and enjoy the archives!</h3>

<div id="archives">

echo $archive_design;

</div><!--end archives-->
  • \$\begingroup\$ This question is nearly 1 year old, are you still looking for advice/review on this question? How are you "archiving" your data? Is there a database table? if not, that is the first step in all of this. The second step is generating an auto-incremented id for each newsletter. When you've done these things, please update your question, and I am happy to offer some additional pieces of advice. (Alternatively, if you are no longer seeking assistance, perhaps delete this question so as to remove this abandoned post.) \$\endgroup\$ – mickmackusa Jun 26 '17 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.