• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP loop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了loop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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($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


示例5: loop

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


示例16: foreach

?>
<? foreach($categories as $cat): ?>
<?php 
if (intval($cat['parent_id']) > 0) {
    $cat['id'] = intval($cat['id']);
    if ($cat['id'] != 0) {
        // p($cat['id']);
        $params = array();
        //$params['display']= 'games_list_single_item.php';
        $params['selected_categories'] = array($cat['id']);
        $params['items_per_page'] = 6;
        $if_posts = get_posts($params);
        $count = count($if_posts);
        if (!empty($if_posts) and $count > 0) {
            ?>
<h1>Newest games from <? print $cat['taxonomy_value'] ?></h1>
<div class="top_games">

<? loop($if_posts, 'games_list_single_item.php', 'the_post') ; ?>

  
  <a class="mw_btn_s right" href="<? print get_category_url($cat['id']); ?>"><span>See all <? print get_category_items_count($cat['id']); ?> games</span></a> </div>
<?php 
        }
    }
}
?>
<? endforeach; ?>
 
开发者ID:Gninety,项目名称:Microweber,代码行数:28,代码来源:most_popular_from_categories.php


示例17: append


//.........这里部分代码省略.........
		height: <?php 
            echo get_option('jwplayer_height_public');
            ?>
		}
		);
		jwplayer("jwplayer_plugin").onReady(function(){
				jwplayer("jwplayer_plugin").seek(startTime);
                            <?php 
            if (get_option('jwplayer_autostart') == 0) {
                ?>
                                jwplayer("jwplayer_plugin").pause();
                            <?php 
            }
            ?>
		}
		);
		<?php 
        }
        ?>
        </script>
            <?php 
        if (get_option('jwplayer_display_current')) {
            ?>
                
                <?php 
            $orig_item = get_current_record('item');
            $orig_video = metadata("item", array("Streaming Video", "Video Filename"));
            ?>
                <?php 
            $items = get_records('item', array('collection' => metadata('item', 'collection id'), 'sort_field' => 'Streaming Video,Segment Start'), null);
            ?>
                
                <?php 
            set_loop_records('items', $items);
            if (has_loop_records('items')) {
                $items = get_loop_records('items');
            }
            ?>
                <?php 
            foreach (loop('items') as $item) {
                ?>
                <?php 
                if (metadata('item', array('Streaming Video', 'Segment Type')) == 'Scene' && metadata('item', array('Streaming Video', 'Video Filename')) == $orig_video) {
                    ?>
                    <div class="scene" id="<?php 
                    echo metadata('item', array('Streaming Video', 'Segment Start'));
                    ?>
" title="<?php 
                    echo metadata('item', array('Streaming Video', 'Segment End'));
                    ?>
" style="display:none;">
                    <h2>Current video segment:</h2>
                    <h3><?php 
                    echo link_to_item(metadata('item', array('Dublin Core', 'Title')));
                    ?>
</h3>
                    <div style="overflow:auto; max-height:150px;">
                    <p> <?php 
                    echo metadata('item', array('Dublin Core', 'Description'));
                    ?>
 </p>
                    </div>
                    <p>Segment:&nbsp<?php 
                    echo metadata('item', array('Streaming Video', 'Segment Start'));
                    ?>
                    --
开发者ID:wmcowan,项目名称:VideoStream,代码行数:67,代码来源:VideoStreamPlugin.php


示例18: branch

    return branch(null, thunk($n), thunk(false), null) !== $n;
}, 'until1' => function ($n) {
    $x = $n % 8;
    return until(function ($args) use($x) {
        list($m, $arr) = $args;
        return [$m === $x, [$m + 1, snoc($m, $arr)]];
    }, [0, []]) !== [$x + 1, upto($x + 1)];
}, 'trampoline1' => function ($n) {
    $x = $n % 8;
    return trampoline(y(function ($f, $m, $n, $_) {
        return $m < $n ? [false, $f($m + 1, $n)] : [true, $m];
    }, 0, $x)) !== $x;
}, 'loop1' => function ($x) {
    $n = $x % 8;
    $lhs = loop(function ($x, $m) use($n) {
        return [$m >= $n, snoc($m, $x)];
    }, []);
    $rhs = upto($n + 1);
    return $lhs === $rhs ? 0 : dump(get_defined_vars());
}, 'y1' => function ($x) {
    $n = $x % 4;
    return y(function ($f, $m) use($n) {
        return $m === $n ? $m : $f($m + 1);
    }, 0) !== $n;
}, 'stream_take1' => function ($x) {
    $n = $x % 8;
    $lhs = upto($n);
    $rhs = stream_take($n, y(function ($f, $n, $_) {
        return [$n, $f($n + 1)];
    }, 0));
    return $lhs === $rhs ? 0 : dump(get_defined_vars());
开发者ID:Warbo,项目名称:php-prelude,代码行数:31,代码来源:tests.php


示例19: browse_sort_links

 echo browse_sort_links(array('Title' => 'Dublin Core,Title'), array(''));
 ?>
                 </div>
                 <div class="col-sm-3">
                     <?php 
 echo browse_sort_links(array('Creator' => 'Dublin Core,Contributor'), array(''));
 ?>
                 </div>
                 <div class="col-sm-4">
                     Description
                 </div>
             </div>
         </div>
     
         <?php 
 foreach (loop('collections') as $collection) {
     ?>
             <div class="collection">
                 <div class="row">
                     <div class="col-sm-2">
                         <?php 
     if ($collectionImage = record_image('collection', 'square_thumbnail')) {
         ?>
                             <?php 
         echo link_to_collection($collectionImage, array('class' => 'image'));
         ?>
                         <?php 
     }
     ?>
                     </div>
                     <div class="col-sm-3">
开发者ID:jeau,项目名称:omeka-starter-theme,代码行数:31,代码来源:browse.php


示例20: reInit

 /**
  * Performs any reinitializing necessary after forking.
  */
 function reInit()
 {
     loop()->reInit();
 }
开发者ID:kayandrae,项目名称:icicle,代码行数:7,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP loop_pagination函数代码示例发布时间:2022-05-15
下一篇:
PHP lookup_type函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap