当前位置: 首页>>代码示例>>PHP>>正文


PHP loop函数代码示例

本文整理汇总了PHP中loop函数的典型用法代码示例。如果您正苦于以下问题:PHP loop函数的具体用法?PHP loop怎么用?PHP loop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loop

function loop($data, $parent)
{
    if (isset($data[$parent])) {
        // jika ada anak dari menu maka tampilkan
        /* setiap menu ditampilkan dengan tag <ul> dan apabila nilai $parent bukan 0 maka sembunyikan element 
         * karena bukan merupakan menu utama melainkan sub menu */
        $str = '<ul parent="' . $parent . '" style="display:' . ($parent > 0 ? 'none' : '') . '">';
        foreach ($data[$parent] as $value) {
            /* variable $child akan bernilai sebuah string apabila ada sub menu dari masing-masing menu utama
             * dan akan bernilai negatif apabila tidak ada sub menu */
            if ($value->TglBaca == "0000-00-00 00:00:00") {
                $statusbaca = "<font color=\"#CC0000\"> Belum dibaca. </font>";
            } else {
                $statusbaca = "Telah dibaca pada " . ViewDateTimeFormat($value->TglBaca) . ".";
            }
            $child = loop($data, $value->IdDisposisi);
            $str .= '<table><tr><td><li>';
            /* beri tanda sebuah folder dengan warna yang mencolok apabila terdapat sub menu di bawah menu utama 	  	   
             * dan beri juga event javascript untuk membuka sub menu di dalamnya */
            $str .= $child ? '<a href="javascript:openTree(' . $value->IdDisposisi . ')"><img src="images/icons/folderclose2.jpg" id="img' . $value->IdDisposisi . '" border="0"></a>' : '<img src="images/icons/folderclose1.jpg">';
            $str .= '<a href="' . $value->url . '"></a> => ' . GetNama($value->IdPenerima) . ' pada ' . ViewDateTimeFormat($value->TglDisposisi) . ' </td></tr><tr><td><font color=#E238EC>Instruksi/Berita : ' . $value->Instruksi . ' </font></td></tr><tr><td><font color=#0000FF>Tanggapan : ' . $value->Tanggapan . '</font></td></tr><tr><td> Status : ' . $statusbaca . ' </td></tr></table></li>';
            if ($child) {
                $str .= $child;
            }
        }
        $str .= '</ul>';
        return $str;
    } else {
        return false;
    }
}
开发者ID:abbeet,项目名称:server39,代码行数:31,代码来源:disposisitreeview.php

示例2: _get_list_of_leaves

 /**
  * Get an array of all leaves (or all non-leaves) of an item in order to
  * display them with BookReader.
  *
  * Difference with the default method is that multiple views and missing
  * pages are added when needed, so the parity remains clean.
  *
  * @param boolean $invert
  *
  * @return array
  *   Array of files or nulls.
  */
 protected function _get_list_of_leaves($invert = false)
 {
     if (empty($this->_item)) {
         return;
     }
     if (is_null($this->_leaves)) {
         $this->_leaves = array();
         $this->_nonleaves = array();
         $supportedFormats = array('jpeg' => 'JPEG Joint Photographic Experts Group JFIF format', 'jpg' => 'Joint Photographic Experts Group JFIF format', 'png' => 'Portable Network Graphics', 'gif' => 'Graphics Interchange Format', 'tif' => 'Tagged Image File Format', 'tiff' => 'Tagged Image File Format');
         // Set the regular expression to match selected/supported formats.
         $supportedFormatRegex = '/\\.(' . implode('|', array_keys($supportedFormats)) . ')$/i';
         // Retrieve image files from the item.
         set_loop_records('files', $this->_item->getFiles());
         foreach (loop('files') as $file) {
             if ($file->hasThumbnail() && preg_match($supportedFormatRegex, $file->filename)) {
                 $this->_leaves[] = $file;
             } else {
                 $this->_nonleaves[] = $file;
             }
         }
         // Sorting by original filename or keep attachment order.
         if (get_option('bookreader_sorting_mode')) {
             $this->sortFilesByOriginalName($this->_leaves);
             $this->sortFilesByOriginalName($this->_nonleaves);
         }
         // Insert missing pages and multiple views.
         $this->_leaves = $this->_complete_list_of_leaves();
         // Reset keys, because the important is to get files by order.
         $this->_leaves = array_values($this->_leaves);
         $this->_nonleaves = array_values($this->_nonleaves);
     }
     return $invert ? $this->_nonleaves : $this->_leaves;
 }
开发者ID:mjlassila,项目名称:BookReader,代码行数:45,代码来源:RefnumOCR.php

示例3: loop

function loop($equipments, $projectId, $ul)
{
    foreach ($equipments as $equipment) {
        $component = $equipment->component;
        $project = $component->project;
        if ($projectId != $component->projectId) {
            $projectId = $component->projectId;
            if ($project->hide) {
                $style = "";
            } else {
                $style = "style='display:none'";
            }
            echo "{$ul}<li class='p{$projectId}' {$style}><span class='folder'>" . $project->identifier . " " . $project->name . "</span>";
            $ul = "</ul></li>";
            echo "<ul>";
        }
        $childs = $equipment->equipments;
        echo "<li><span class='equipment'>" . CHtml::link($component->identifier . $equipment->identifier, array('view', 'id' => $equipment->id)) . " - " . CHtml::encode($equipment->description) . "</span>";
        if ($childs) {
            echo "<ul>";
            loop($childs, $projectId, $ul);
            echo "</ul>";
        } else {
            echo "</li>";
        }
    }
}
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:27,代码来源:assembly.php

示例4: loop

function loop($a, &$b)
{
    echo '* ';
    if ($a <= $b) {
        return;
    }
    loop($a--, ++$b);
}
开发者ID:weusder,项目名称:php-certification-studies,代码行数:8,代码来源:loop-trick.php

示例5: loop

function loop($equipments, $projectId, $ul)
{
    foreach ($equipments as $equipment) {
        $component = $equipment->component;
        $project = $component->project;
        if ($projectId != $component->projectId) {
            $projectId = $component->projectId;
            if ($project->hide) {
                $style = "";
            } else {
                $style = "style='display:none'";
            }
            echo "{$ul}<li class='p{$projectId}' {$style}><span class='project' title='Project'>" . $project->identifier . " " . $project->name . "</span>";
            $ul = "</ul></li>";
            echo "<ul>";
        }
        $childs = $equipment->equipments;
        if ($equipment->status == 1) {
            echo "<li><span class='equipment'>" . CHtml::link($component->identifier . $equipment->identifier, array('view', 'id' => $equipment->id), array('onclick' => 'mostra_loading_screen()')) . " - " . CHtml::encode($equipment->description) . "</span>";
        } else {
            echo "<li><span class='equipment'>" . CHtml::link($component->identifier . $equipment->identifier, array('view', 'id' => $equipment->id), array('onclick' => 'mostra_loading_screen()')) . " - <b class=green >" . CHtml::encode($equipment->description) . "</b></span>";
        }
        if ($childs) {
            echo "<ul>";
            loop($childs, $projectId, $ul);
            echo "</ul>";
        } else {
            echo "</li>";
        }
    }
}
开发者ID:Romandre90,项目名称:vectortraveler,代码行数:31,代码来源:assembly.php

示例6: get_first_collection_images

function get_first_collection_images()
{
    if (metadata('collection', 'total_items') > 0) {
        /* find child items  */
        $collectionId = metadata('collection', 'id');
        $childArray = get_child_collections($collectionId);
        $thumbnailCount = 0;
        $childCount = 0;
        while ($thumbnailCount <= 3) {
            $childID = $childArray[$childCount]['id'];
            set_current_record('collection', get_record_by_id('collection', $childID));
            while (loop('items') and $thumbnailCount <= 3) {
                echo item_thumbnail();
                $thumbnailCount++;
            }
            $childCount++;
        }
    } else {
        while (loop('items', 4)) {
            echo item_thumbnail();
        }
        return $html;
    }
}
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:24,代码来源:custom.php

示例7: browse_sort_links

 $browseHeadings[__('Item')] = null;
 $browseHeadings[__('Contributor')] = 'contributor';
 if ($allowToManage) {
     $browseHeadings[__('Publication Status')] = null;
 } else {
     $browseHeadings[__('Publication Status')] = null;
 }
 $browseHeadings[__('Date Added')] = 'added';
 echo browse_sort_links($browseHeadings, array('link_tag' => 'th scope="col"', 'list_tag' => ''));
 ?>
         </tr>
     </thead>
     <tbody id="types-table-body">
         <?php 
 $key = 0;
 foreach (loop('contribution_contributed_items') as $contributedItem) {
     $item = $contributedItem->Item;
     $contributor = $contributedItem->Contributor;
     if ($contributor->id) {
         $contributorUrl = url('contribution/contributors/show/id/' . $contributor->id);
     }
     if ($item->public) {
         $status = 'approved';
         if ($allowToManage) {
             $statusText = __('Public (click to put in review)');
         } else {
             $statusText = __('Public');
         }
     } else {
         if ($contributedItem->public) {
             $status = 'proposed';
开发者ID:KelvinSmithLibrary,项目名称:playhouse,代码行数:31,代码来源:browse.php

示例8: metadata

</h2>

    <div id="description" class="element">
        <div class="element-text"><?php 
echo metadata('collection', array('Dublin Core', 'Description'));
?>
</div>
    </div><!-- end description -->

    <div id="collection-items span12">

        <ul class="thumbnails">
        <?php 
$collection_items = get_records('Item', array('collection' => $collection['id'], 'sort_field' => 'Scripto,Weight', 'sort_dir' => 'a'), 999);
set_loop_records('items', $collection_items);
foreach (loop('items') as $item) {
    set_current_record('item', $item);
    if (metadata($item, 'has thumbnail')) {
        ?>
            <li>
                <div id="col-images" class="thumbnail right-caption span4">
                    <?php 
        echo link_to_item(item_image('square_thumbnail', array('alt' => metadata($item, array('Dublin Core', 'Title')), 'class' => 'span2')));
        ?>
                    <div class="caption">
                        <?php 
        echo link_to_item(metadata($item, array('Dublin Core', 'Title'), array('snippet' => 60)), array('class' => 'permalink'));
        ?>
<br /><br />
                        <div id="col-progress">
                            <?php 
开发者ID:HCDigitalScholarship,项目名称:tichadocs_scribe,代码行数:31,代码来源:show.php

示例9: rand

{
    if ($actual < $range['low']) {
        $next = rand($range['low'], $range['high']);
    } else {
        $next = $actual + rand(-1, 1);
    }
    if ($next < $range['low']) {
        $next = $range['low'] + 1;
    }
    if ($next > $range['high']) {
        $next = $range['high'] - 1;
    }
    return $next;
}
function loop($units)
{
    printf("Loop every %ss\n", SLEEP_SECONDS);
    $serial = getSerialConnection();
    while (true) {
        foreach ($units as &$unit) {
            $unit['actual'] = get_next_value($unit['actual'], $unit['range']);
            print "Sending {$unit['actual']} .. ";
            $value = chr($unit['actual']);
            $serial->sendMessage($value);
            print "OK\n";
            usleep(SLEEP_SECONDS * 1000000);
        }
    }
}
loop($units);
开发者ID:adryledo,项目名称:arduino-stuff,代码行数:30,代码来源:generator.php

示例10: __

            <th><?php 
    echo __('Item Number');
    ?>
</th>
            <th><?php 
    echo __('Collection');
    ?>
</th>
        </tr>
    </thead>
    <tbody>
        <?php 
    $filter = new Zend_Filter_Word_CamelCaseToDash();
    ?>
        <?php 
    foreach (loop('search_texts') as $searchText) {
        ?>
        <?php 
        $record = get_record_by_id($searchText['record_type'], $searchText['record_id']);
        ?>
        <?php 
        $recordType = $searchText['record_type'];
        ?>
        <?php 
        set_current_record($recordType, $record);
        ?>
        <tr class="<?php 
        echo strtolower($filter->filter($recordType));
        ?>
">
开发者ID:KelvinSmithLibrary,项目名称:playhouse,代码行数:30,代码来源:index.php

示例11: array

 * The public browse view for Timelines.
 */
$head = array('bodyclass' => 'timelines primary', 'title' => html_escape(__('Browse Timelines')));
echo head($head);
?>

<div class="timelines">
<h1><?php 
echo __('Browse Timelines');
?>
</h1>
    <?php 
if ($total_results) {
    ?>
    <?php 
    foreach (loop('Neatline_Time_Timelines') as $timeline) {
        ?>
    <div class="timeline">
        <h2><?php 
        echo link_to($timeline, 'show', $timeline->title);
        ?>
</h2>
        <?php 
        echo snippet_by_word_count(metadata($timeline, 'description'), '10');
        ?>
    </div>
    <?php 
    }
    ?>
    <div class="pagination">
      <?php 
开发者ID:rameysar,项目名称:Omeka-Grinnell-RomanCiv,代码行数:31,代码来源:browse.php

示例12: _createCollectionFolders

 /**
  * Create collection folders if needed.
  *
  * @return void.
  */
 protected function _createCollectionFolders()
 {
     if (get_option('archive_repertory_collection_convert') != 'None') {
         $collections = get_records('Collection', array(), 0);
         $collectionNames = unserialize(get_option('archive_repertory_collection_names'));
         set_loop_records('collections', $collections);
         foreach (loop('collections') as $collection) {
             $result = $this->_createArchiveFolders($collectionNames[$collection->id]);
         }
     }
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:16,代码来源:ArchiveRepertoryPlugin.php

示例13: scrape

function scrape($source)
{
    //while ook in aparte functie gieten voor hergebruik google of bing of specifieke site
    loop($source);
}
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:5,代码来源:404_scraper.php

示例14: __

  <h1><?php 
echo __('Escolha o seu mapa ou roteiro');
?>
</h1>

  <?php 
if (nl_exhibitsHaveBeenCreated()) {
    ?>

    <div class="pagination"><?php 
    echo pagination_links();
    ?>
</div>

      <?php 
    foreach (loop('NeatlineExhibit') as $e) {
        ?>
          <h2 style="font-weight:300;">
          <?php 
        echo nl_getExhibitLink($e, 'fullscreen', nl_getExhibitField('title'), array('class' => 'neatline'), true);
        ?>
        </h2>
        <h3 style="font-weight:300;">
          <?php 
        $description = truncateText(nl_getExhibitField('narrative'), 100);
        ?>
          <?php 
        echo $description;
        ?>
        </h3>
      <?php 
开发者ID:libraryman,项目名称:guarani,代码行数:31,代码来源:browse.php

示例15: browse_sort_links

<table class="full">
    <thead>
        <tr>
            <?php 
echo browse_sort_links(array(__('Title') => 'title', __('Slug') => 'slug', __('Last Modified') => 'updated'), array('link_tag' => 'th scope="col"', 'list_tag' => ''));
?>
        </tr>
    </thead>
    <tbody>
    <?php 
foreach (loop('simple_pages_pages') as $simplePage) {
    ?>
        <tr>
            <td>
                <span class="title">
                    <a href="<?php 
    echo html_escape(record_url('simple_pages_page'));
    ?>
">
                        <?php 
    echo metadata('simple_pages_page', 'title');
    ?>
                    </a>
                    <?php 
    if (!metadata('simple_pages_page', 'is_published')) {
        ?>
                        (<?php 
        echo __('Private');
        ?>
)
                    <?php 
开发者ID:lchen01,项目名称:STEdwards,代码行数:31,代码来源:browse-list.php


注:本文中的loop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。