Output Array Contents as HTML

I have a PHP array (take a look here) and I'm trying to loop over it and output the data as HTML list. The fields I am trying to show are only content and createdAt.

Here is the HTML template I have in mind, I just need to output the data in a similar way.

<div class="pages">
  <div data-page="projects" class="page no-toolbar no-navbar">
    <div class="page-content">
      <div class="navbarpages">
        <div class="navbar_home_link">
          <a href="index.html">
            <img src="images/icons/white/home.png" alt="" title="" />
          </a>
        </div>
        <div class="navbar_page_center">ALLE ZITATE</div>
        <div class="menu_open_icon_white">
          <a href="#" class="open-panel">
            <img src="images/menu_open.png" alt="" title="" />
          </a>
        </div>
      </div>
      <div id="pages_maincontent">
        <h2 class="page_subtitle">Alle Zitate</h2>
        <ul class="features_list_detailed">
          <li class="swipeout">
            <div class="swipeout-content item-content">
              <div class="post_entry">
                <div class="post_thumb">
                  <div style="font-size: 30px; font-style: bold;">24</div>
                  <div style="text-transform: uppercase; font-style: bold;">January</div>
                </div>
                <div class="post_details">
                  <p>
                    <strong>
                    "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium"
                    </strong>
                  </p>
                </div>
              </div>
            </div>
          </li>
          <li class="swipeout">
            <div class="swipeout-content item-content">
              <div class="post_entry">
                <div class="post_thumb">
                  <div style="font-size: 30px; font-style: bold;">24</div>
                  <div style="text-transform: uppercase; font-style: bold;">January</div>
                </div>
                <div class="post_details">
                  <p>
                    <strong>
                    "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium"
                    </strong>
                  </p>
                </div>
              </div>
            </div>
          </li>
        </ul>

Could someone please help? Thanks in advance.

1 answer

  • answered 2018-01-14 02:54 Innervisions

    Here is a really basic example

      <?php 
            $list = array("value1","value2","value3","value4");
    
            foreach ($list as $list_values) {
                ?>
                <li><?php echo $list_values; ?></li>
                <?php
            }
        ?>
    

    You just foreach inside your array and than put the html inside it and it will loop your html X amount of times