输出数组内容为HTML

时间:2018-01-14 02:47:24

标签: php html arrays loops html-lists

我有一个PHP数组(看看here),我试图循环它并将数据输出为HTML列表。我要显示的字段仅为contentcreatedAt

这是我想到的HTML模板,我只需要以类似的方式输出数据。



<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>
&#13;
&#13;
&#13;

有人可以帮忙吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

这是一个非常基本的例子

  <?php 
        $list = array("value1","value2","value3","value4");

        foreach ($list as $list_values) {
            ?>
            <li><?php echo $list_values; ?></li>
            <?php
        }
    ?>

你只是在你的数组内部,而不是将html放在其中,它将循环你的html X次