當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper::getLastKeyOfArray方法代碼示例

本文整理匯總了PHP中app\helpers\Helper::getLastKeyOfArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::getLastKeyOfArray方法的具體用法?PHP Helper::getLastKeyOfArray怎麽用?PHP Helper::getLastKeyOfArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\helpers\Helper的用法示例。


在下文中一共展示了Helper::getLastKeyOfArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: recommendedProducts

 public static function recommendedProducts(array $products)
 {
     $output = '<div id = "recommended-item-carousel" class = "carousel slide" data-ride = "carousel">' . "\n";
     $output .= '<div class = "carousel-inner">' . "\n";
     $row = $slides = '';
     foreach ($products as $key => $p) {
         $slides .= "\n" . '<div class = "col-sm-4">' . "\n";
         $slides .= '<div class = "product-image-wrapper">' . "\n";
         $slides .= '<div class = "single-products">' . "\n";
         $slides .= '<div class = "productinfo text-center">' . "\n";
         $slides .= '<img src = "/' . $p['image'] . '" alt = "' . $p['title'] . '" />' . "\n";
         $slides .= '<h2>' . $p['price'] . ' <i class="fa fa-rub"></i></h2>' . "\n";
         $slides .= '<p>' . $p['title'] . '</p>' . "\n";
         $slides .= '<a href = "' . $p['id'] . '" class = "btn btn-default add-to-cart"><i class = "fa fa-shopping-cart"></i>Добавить в корзину</a>' . "\n";
         $slides .= '</div>' . "\n";
         $slides .= '</div>' . "\n";
         $slides .= '</div>' . "\n";
         $slides .= '</div>' . "\n";
         ++$key;
         if ($key !== 0 && $key % 3 === 0 || --$key === Helper::getLastKeyOfArray($products)) {
             $active = empty($row) ? ' active' : '';
             $row .= '<div class = "item' . $active . '">' . $slides . '</div>' . "\n";
             $slides = '';
         }
     }
     $output .= $row;
     $output .= '</div>' . "\n";
     $output .= '<a class = "left recommended-item-control" href = "#recommended-item-carousel" data-slide = "prev">
             <i class = "fa fa-angle-left"></i>
         </a>
         <a class = "right recommended-item-control" href = "#recommended-item-carousel" data-slide = "next">
             <i class = "fa fa-angle-right"></i>
         </a>' . "\n";
     $output .= '</div>' . "\n";
     return $output;
 }
開發者ID:ralf000,項目名稱:newshop,代碼行數:36,代碼來源:Generator.class.php


注:本文中的app\helpers\Helper::getLastKeyOfArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。