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


PHP array_slice函数代码示例

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


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

示例1: get

 public function get($limit = 1024)
 {
     header('Content-Type: application/json');
     $dates = json_decode(file_get_contents('hoa://Application/Database/Dates.json'), true);
     echo json_encode(array_slice($dates, 0, $limit));
     return;
 }
开发者ID:Hywan,项目名称:Amine_and_Hamza,代码行数:7,代码来源:Dates.php

示例2: onls

 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:28,代码来源:log.php

示例3: autoload_framework_classes

/**
 * Function used to auto load the framework classes
 * 
 * It imlements PSR-0 and PSR-4 autoloading standards
 * The required class name should be prefixed with a namespace
 * This lowercaser of the namespace should match the folder name of the class 
 * 
 * @since 1.0.0
 * @param string $class_name name of the class that needs to be included
 */
function autoload_framework_classes($class_name)
{
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    ini_set('display_startup_errors', true);
    /** If the required class is in the global namespace then no need to autoload the class */
    if (strpos($class_name, "\\") === false) {
        return false;
    }
    /** The namespace seperator is replaced with directory seperator */
    $class_name = str_replace("\\", DIRECTORY_SEPARATOR, $class_name);
    /** The class name is split into namespace and short class name */
    $path_info = explode(DIRECTORY_SEPARATOR, $class_name);
    /** The namepsace is extracted */
    $namespace = implode(DIRECTORY_SEPARATOR, array_slice($path_info, 0, count($path_info) - 1));
    /** The class name is extracted */
    $class_name = $path_info[count($path_info) - 1];
    /** The namespace is converted to lower case */
    $namespace_folder = trim(strtolower($namespace), DIRECTORY_SEPARATOR);
    /** .php is added to class name */
    $class_name = $class_name . ".php";
    /** The applications folder name */
    $framework_folder_path = realpath(dirname(__FILE__));
    /** The application folder is checked for file name */
    $file_name = $framework_folder_path . DIRECTORY_SEPARATOR . $namespace_folder . DIRECTORY_SEPARATOR . $class_name;
    if (is_file($file_name)) {
        include_once $file_name;
    }
}
开发者ID:pluginscart,项目名称:Pak-PHP,代码行数:39,代码来源:autoload.php

示例4: match

 /**
  *
  * @see XenForo_Route_PrefixAdmin_AddOns::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $parts = explode('/', $routePath, 3);
     switch ($parts[0]) {
         case 'languages':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
             return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
         case 'phrases':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
     }
     if (count($parts) > 1) {
         switch ($parts[1]) {
             case 'languages':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
             case 'phrases':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
         }
     }
     return parent::match($routePath, $request, $router);
 }
开发者ID:ThemeHouse-XF,项目名称:Phrases,代码行数:35,代码来源:AddOns.php

示例5: _parse_doc_comment

 protected static function _parse_doc_comment($comment)
 {
     // Normalize all new lines to \n
     $comment = str_replace(array("\r\n", "\n"), "\n", $comment);
     // Remove the phpdoc open/close tags and split
     $comment = array_slice(explode("\n", $comment), 1, -1);
     // Tag content
     $param = array();
     foreach ($comment as $i => $line) {
         // Remove all leading whitespace
         $line = preg_replace('/^\\s*\\* ?/m', '', $line);
         // Search this line for a tag
         if (preg_match('/^@(\\S+)(?:\\s*(.+))?$/', $line, $matches)) {
             // This is a tag line
             unset($comment[$i]);
             $name = $matches[1];
             $text = isset($matches[2]) ? $matches[2] : '';
             if ($text && $name == 'param') {
                 // Add the tag
                 $param[] = $text;
             } else {
                 continue;
             }
         } else {
             // Overwrite the comment line
             $comment[$i] = (string) $line;
         }
     }
     return array('title' => $comment, 'param' => $param);
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:30,代码来源:shell.controller.php

示例6: Render

  function Render()
  {
    global $currentUser;
    if (!$currentUser)
      return;

    if (!$currentUser->CanSubmitItems())
      return;

    echo "\n\n";
    echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";

    echo "  <h2>".$this->title."</h2>\n";
    echo "  <div class='content'>\n";

    $width = 15;

    $g = glob(POUET_CONTENT_LOCAL."avatars/*.gif");
    shuffle($g);
    $g = array_slice($g,0,$width * $width);

    echo "<ul id='avatargallery'>\n";
    foreach($g as $v)
      printf("  <li><img src='".POUET_CONTENT_URL."avatars/%s' alt='%s' title='%s'/></li>\n",basename($v),basename($v),basename($v));
    echo "</ul>\n";

    echo "  </div>\n";
    echo "</div>\n";
  }
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:29,代码来源:submit_avatar.php

示例7: execute

 /**
  * Execute requested action
  */
 public function execute()
 {
     $method = $_SERVER['REQUEST_METHOD'];
     $verbs = $this->verbs();
     if (isset($verbs[$this->requestMethod])) {
         $action = 'action' . ucfirst(mb_strtolower($verbs[$method]));
         $reflectionMethod = new \ReflectionMethod($this, $action);
         $parsePath = array_slice($this->path, count($this->route));
         $args = [];
         $errors = [];
         if ($params = $reflectionMethod->getParameters()) {
             foreach ($params as $key => $param) {
                 if (isset($parsePath[$key])) {
                     $args[$param->name] = $parsePath[$key];
                 } else {
                     $errors[] = ['code' => 'required', 'message' => ucfirst(mb_strtolower(explode('_', $param->name)[0])) . ' cannot be blank.', 'name' => $param->name];
                 }
             }
             if ($errors) {
                 throw new \phantomd\ShopCart\modules\base\HttpException(400, 'Invalid data parameters', 0, null, $errors);
             }
         }
         if (count($parsePath) === count($params)) {
             return call_user_func_array([$this, $action], $args);
         }
     }
     throw new HttpException(404, 'Unable to resolve the request "' . $this->requestPath . '".', 0, null, $errors);
 }
开发者ID:phantom-d,项目名称:shop-cart,代码行数:31,代码来源:BaseController.php

示例8: Folder

 function Folder(&$tdb, $arrayValues, $childInfo = FALSE, $nested = false)
 {
     $this->tdb = $tdb;
     $this->id = $arrayValues[0];
     $this->idParent = $arrayValues[1];
     $this->path = $arrayValues[2];
     $this->level = $arrayValues[3];
     $this->nested = $nested;
     if ($nested) {
         $this->iLeft = $arrayValues[4];
         $this->iRight = $arrayValues[5];
         if ($childInfo) {
             $this->otherValues = array_slice($arrayValues, 7);
             $this->countChildrens = $arrayValues[6];
         } else {
             if (is_array($arrayValues)) {
                 $this->otherValues = array_slice($arrayValues, 6);
                 $this->hasChildrens = NULL;
             }
         }
     } else {
         if ($childInfo) {
             $this->otherValues = array_slice($arrayValues, 5);
             $this->countChildrens = $arrayValues[4];
         } else {
             if (is_array($arrayValues)) {
                 $this->otherValues = array_slice($arrayValues, 4);
                 $this->hasChildrens = NULL;
             }
         }
     }
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:32,代码来源:lib.treedb.php

示例9: addCommandsFromClass

 public function addCommandsFromClass($className, $passThrough = null)
 {
     $roboTasks = new $className();
     $commandNames = array_filter(get_class_methods($className), function ($m) {
         return !in_array($m, ['__construct']);
     });
     foreach ($commandNames as $commandName) {
         $command = $this->createCommand(new TaskInfo($className, $commandName));
         $command->setCode(function (InputInterface $input) use($roboTasks, $commandName, $passThrough) {
             // get passthru args
             $args = $input->getArguments();
             array_shift($args);
             if ($passThrough) {
                 $args[key(array_slice($args, -1, 1, TRUE))] = $passThrough;
             }
             $args[] = $input->getOptions();
             $res = call_user_func_array([$roboTasks, $commandName], $args);
             if (is_int($res)) {
                 exit($res);
             }
             if (is_bool($res)) {
                 exit($res ? 0 : 1);
             }
             if ($res instanceof Result) {
                 exit($res->getExitCode());
             }
         });
         $this->add($command);
     }
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:30,代码来源:Application.php

示例10: __construct

 function __construct()
 {
     // Extract the query from the tag chunk
     if (($sql = ee()->TMPL->fetch_param('sql')) === FALSE) {
         return FALSE;
     }
     // Rudimentary check to see if it's a SELECT query, most definitely not
     // bulletproof
     if (substr(strtolower(trim($sql)), 0, 6) != 'select') {
         return FALSE;
     }
     $query = ee()->db->query($sql);
     $results = $query->result_array();
     if ($query->num_rows() == 0) {
         return $this->return_data = ee()->TMPL->no_results();
     }
     // Start up pagination
     ee()->load->library('pagination');
     $pagination = ee()->pagination->create();
     ee()->TMPL->tagdata = $pagination->prepare(ee()->TMPL->tagdata);
     $per_page = ee()->TMPL->fetch_param('limit', 0);
     // Disable pagination if the limit parameter isn't set
     if (empty($per_page)) {
         $pagination->paginate = FALSE;
     }
     if ($pagination->paginate) {
         $pagination->build($query->num_rows(), $per_page);
         $results = array_slice($results, $pagination->offset, $pagination->per_page);
     }
     $this->return_data = ee()->TMPL->parse_variables(ee()->TMPL->tagdata, array_values($results));
     if ($pagination->paginate === TRUE) {
         $this->return_data = $pagination->render($this->return_data);
     }
 }
开发者ID:stb74,项目名称:eeguide,代码行数:34,代码来源:mod.query.php

示例11: get_datas

 public function get_datas()
 {
     global $dbh;
     $return = array();
     $selector = $this->get_selected_selector();
     if ($selector) {
         $value = $selector->get_value();
         $records = array();
         if (is_array($value) && count($value)) {
             for ($i = 0; $i < count($value); $i++) {
                 $query = "select notice_id from notices where notice_id='" . $value[$i] . "'";
                 $result = pmb_mysql_query($query, $dbh);
                 if (pmb_mysql_num_rows($result) > 0) {
                     $row = pmb_mysql_fetch_object($result);
                     $records[] = $row->notice_id;
                 }
             }
             $records = array_reverse($records);
             $return['records'] = $this->filter_datas("notices", $records);
             if ($this->parameters['nb_max_elements'] > 0) {
                 $return['records'] = array_slice($return['records'], 0, $this->parameters['nb_max_elements']);
             }
         }
         return $return;
     }
     return false;
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:27,代码来源:cms_module_recordslist_datasource_records_last_read.class.php

示例12: modelUserTag

 protected function modelUserTag($limit)
 {
     $tags = Wekit::load('usertag.srv.PwUserTagService')->getUserTagList($this->spaceUid);
     $count = count($tags);
     $tags = is_array($tags) ? array_slice($tags, 0, $limit, true) : array();
     return array($count, $tags);
 }
开发者ID:YoursBoss,项目名称:nextwind,代码行数:7,代码来源:PwSpaceModel.php

示例13: do_main

 function do_main()
 {
     $notifications = (array) KTNotification::getList(array("user_id = ?", $this->oUser->getId()));
     $num_notifications = count($notifications);
     $PAGE_SIZE = 5;
     $page = (int) KTUtil::arrayGet($_REQUEST, 'page', 0);
     $page_count = ceil($num_notifications / $PAGE_SIZE);
     if ($page >= $page_count) {
         $page = $page_count - 1;
     }
     if ($page < 0) {
         $page = 0;
     }
     // slice the notification array.
     $notifications = array_slice($notifications, $page * $PAGE_SIZE, $PAGE_SIZE);
     // prepare the batch html.  easier to do this here than in the template.
     $batch = array();
     for ($i = 0; $i < $page_count; $i++) {
         if ($i == $page) {
             $batch[] = sprintf("<strong>%d</strong>", $i + 1);
         } else {
             $batch[] = sprintf('<a href="%s">%d</a>', KTUtil::addQueryStringSelf($this->meldPersistQuery(array("page" => $i), "main", true)), $i + 1);
         }
     }
     $batch_html = implode(' &middot; ', $batch);
     $count_string = sprintf(_kt("Showing Notifications %d - %d of %d"), $page * $PAGE_SIZE + 1, min(($page + 1) * $PAGE_SIZE, $num_notifications), $num_notifications);
     $this->oPage->setTitle(_kt("Items that require your attention"));
     $oTemplate =& $this->oValidator->validateTemplate("ktcore/misc/notification_overflow");
     $oTemplate->setData(array('count_string' => $count_string, 'batch_html' => $batch_html, 'notifications' => $notifications));
     return $oTemplate->render();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:31,代码来源:KTMiscPages.php

示例14: newRequest

 /**
  * Checks the queue for matches to this request.
  * If a group can be formed, returns an array with the sessions that will form this group.
  * Otherwise, returns FALSE.
  *
  * @param GroupRequest $request
  * @return array<Session> if a group can be formed, FALSE otherwise
  */
 public function newRequest(GroupRequest $request)
 {
     // filter all requests that match this one
     $matches = array_filter($this->requests, function ($potential_match) use($request) {
         return !$potential_match->expired() && $request->match($potential_match);
     });
     if (count($matches) + 1 >= $request->size()) {
         // we have enough people to form a group!
         // get as many of the matches as we need for the group
         $selected_requests = array_slice($matches, 0, $request->size() - 1);
         // remove the fulfilled grouprequests from the queue
         $this->removeRequests($selected_requests);
         // get the sessions that will make up this group
         $sessions = array_map(function ($selected_request) {
             return $selected_request->session;
         }, $selected_requests);
         $sessions[] = $request->session;
         // don't forget the new request
         return $sessions;
     } else {
         // not enough requests matching this one
         // add this request to the queue
         $this->addRequest($request);
         return FALSE;
     }
 }
开发者ID:nmalkin,项目名称:basset,代码行数:34,代码来源:grouprequestqueue.php

示例15: index

 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $gallery = Page::where('slug', '=', 'gallery')->first();
     $images = explode(',', $gallery->content);
     $images = array_slice($images, 0, 16);
     return view('frontend.index', ['images' => $images]);
 }
开发者ID:aysenli,项目名称:laravel5-backend,代码行数:12,代码来源:WelcomeController.php


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