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


PHP str::split方法代码示例

本文整理汇总了PHP中str::split方法的典型用法代码示例。如果您正苦于以下问题:PHP str::split方法的具体用法?PHP str::split怎么用?PHP str::split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在str的用法示例。


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

示例1: register

 /**
  * Adds a new route
  *
  * @param object $route
  * @return object
  */
 public function register($pattern, $params = array(), $optional = array())
 {
     if (is_array($pattern)) {
         foreach ($pattern as $v) {
             $this->register($v['pattern'], $v);
         }
         return $this;
     }
     $defaults = array('pattern' => $pattern, 'https' => false, 'ajax' => false, 'filter' => null, 'method' => 'GET', 'arguments' => array());
     $route = new Obj(array_merge($defaults, $params, $optional));
     // convert single methods or methods separated by | to arrays
     if (is_string($route->method)) {
         if (strpos($route->method, '|') !== false) {
             $route->method = str::split($route->method, '|');
         } else {
             if ($route->method == 'ALL') {
                 $route->method = array_keys($this->routes);
             } else {
                 $route->method = array($route->method);
             }
         }
     }
     foreach ($route->method as $method) {
         $this->routes[strtoupper($method)][$route->pattern] = $route;
     }
     return $route;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:33,代码来源:router.php

示例2: tagcloud

function tagcloud($parent, $options = array())
{
    global $site;
    // default values
    $defaults = array('limit' => false, 'field' => 'tags', 'children' => 'visible', 'baseurl' => $parent->url(), 'param' => 'tag', 'sort' => 'name', 'sortdir' => 'asc');
    // merge defaults and options
    $options = array_merge($defaults, $options);
    switch ($options['children']) {
        case 'invisible':
            $children = $parent->children()->invisible();
            break;
        case 'visible':
            $children = $parent->children()->visible();
            break;
        default:
            $children = $parent->children();
            break;
    }
    $cloud = array();
    foreach ($children as $p) {
        $tags = str::split($p->{$options}['field']());
        foreach ($tags as $t) {
            if (isset($cloud[$t])) {
                $cloud[$t]->results++;
            } else {
                $cloud[$t] = new obj(array('results' => 1, 'name' => $t, 'url' => $options['baseurl'] . '/' . $options['param'] . ':' . $t, 'isActive' => param($options['param']) == $t ? true : false));
            }
        }
    }
    $cloud = a::sort($cloud, $options['sort'], $options['sortdir']);
    if ($options['limit']) {
        $cloud = array_slice($cloud, 0, $options['limit']);
    }
    return $cloud;
}
开发者ID:niklausgerber,项目名称:themis,代码行数:35,代码来源:tagcloud.php

示例3: crawl

 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:28,代码来源:uri.php

示例4: getDay

 public function getDay($date)
 {
     $Date = str::split($date, '-');
     // If day folder doesn't exists, create it
     $this->field()->check_day($this->model(), $date);
     // Go to day edit page
     go(purl($this->model(), 'year-' . $Date[0] . '/day-' . $date . '/edit/'));
 }
开发者ID:molocLab,项目名称:kirby-calendar-board,代码行数:8,代码来源:controller.php

示例5: value

 public function value()
 {
     $value = InputListField::value();
     if (is_array($value)) {
         return $value;
     } else {
         return str::split($value, ',');
     }
 }
开发者ID:madebypost,项目名称:Gulp-Neat-KirbyCMS,代码行数:9,代码来源:checkboxes.php

示例6: value

 public function value()
 {
     $value = parent::value();
     if (is_array($value)) {
         return $value;
     } else {
         return str::split($value, ',');
     }
 }
开发者ID:kompuser,项目名称:panel,代码行数:9,代码来源:checkboxes.php

示例7: slugTable

function slugTable()
{
    $table = array();
    foreach (str::$ascii as $key => $value) {
        $key = trim($key, '/');
        foreach (str::split($key, '|') as $needle) {
            $table[$needle] = $value;
        }
    }
    return json_encode($table, JSON_UNESCAPED_UNICODE);
}
开发者ID:nsteiner,项目名称:kdoc,代码行数:11,代码来源:helpers.php

示例8: bgimage

/**
 * imgsrc Plugin
 *
 * @author Marijn Tijhuis <marijn@studiodumbar.com>
 * @author Jonathan van Wunnik <jonathan@studiodumbar.com.com>
 * @version 1.0.0
 */
function bgimage($image = false, $options = array())
{
    if (!$image) {
        return;
    }
    // Default key values
    $defaults = array('width' => null, 'height' => null, 'crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'quality' => c::get('thumbs.quality', 92), 'lazyload' => c::get('lazyload', false));
    // Merge defaults and options
    $options = array_merge($defaults, $options);
    // Without resrc, maximize thumb width, for speedier loading of page!
    if (c::get('resrc') == false) {
        if (!isset($options['width'])) {
            $thumbwidth = c::get('thumbs.width.default', 800);
        } else {
            $thumbwidth = $options['width'];
        }
    } else {
        // If resrc is enabled, use original image width
        $thumbwidth = $image->width();
    }
    // If no crop variable is defined *and* no cropratio
    // is set, the crop variable is set to false
    if (!isset($options['crop']) && !isset($options['cropratio'])) {
        $options['crop'] = false;
    }
    // When a cropratio is set, calculate the ratio based height
    if (isset($options['cropratio'])) {
        // If cropratio is a fraction string (e.g. 1/2), convert to decimal
        if (strpos($options['cropratio'], '/') !== false) {
            list($numerator, $denominator) = str::split($options['cropratio'], '/');
            $options['cropratio'] = $numerator / $denominator;
        }
        // Calculate new thumb height based on cropratio
        $thumbheight = round($thumbwidth * $options['cropratio']);
        // If a cropratio is set, the crop variable is always set to true
        $options['crop'] = true;
        // Manual set (crop)ratio
        $ratio = $options['cropratio'];
    } else {
        // Intrinsic image's ratio
        $ratio = 1 / $image->ratio();
        // Max. height of image
        $thumbheight = round($thumbwidth * $ratio);
    }
    // Create thumb url (create a new thumb object)
    $options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'quality' => $options['quality'], 'crop' => $options['crop']), false);
    // Add more values to options array, for use in template
    $options['customwidth'] = $options['width'];
    $options['customquality'] = $options['quality'];
    $options['ratio'] = $ratio;
    // Return template HTML
    return tpl::load(__DIR__ . DS . 'template/bgimage.php', $options);
}
开发者ID:veryrobert,项目名称:altair,代码行数:60,代码来源:bgimage.php

示例9: path

 function path($key = null, $default = null)
 {
     $path = self::$path;
     if (!$path) {
         $path = url::strip_query(self::raw());
         $path = (array) str::split($path, '/');
         self::$path = $path;
     }
     if ($key === null) {
         return $path;
     }
     return a::get($path, $key, $default);
 }
开发者ID:o-github-o,项目名称:jQuery-Ajax-Upload,代码行数:13,代码来源:uri.php

示例10: entry

 /**
  * Returns a registry entry object by type
  * 
  * @param string $type
  * @param string $subtype
  * @return Kirby\Registry\Entry
  */
 public function entry($type, $subtype = null)
 {
     $class = 'kirby\\registry\\' . $type;
     if (!class_exists('kirby\\registry\\' . $type)) {
         if (str::contains($type, '::')) {
             $parts = str::split($type, '::');
             $subtype = $parts[0];
             $type = $parts[1];
             return $this->entry($type, $subtype);
         }
         throw new Exception('Unsupported registry entry type: ' . $type);
     }
     return new $class($this, $subtype);
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:21,代码来源:registry.php

示例11: figure

/**
 * Figure Plugin
 *
 * @author Marijn Tijhuis <marijn@studiodumbar.com>
 * @author Jonathan van Wunnik <jonathan@studiodumbar.com.com>
 * @version 1.0.0
 */
function figure($image = false, $options = array())
{
    if (!$image) {
        return;
    }
    // default key values
    $defaults = array('crop' => null, 'cropratio' => null, 'class' => '', 'alt' => '', 'caption' => null, 'lazyload' => c::get('lazyload', false));
    // merge defaults and options
    $options = array_merge($defaults, $options);
    // without resrc, maximize thumb width, for speedier loading of page!
    if (c::get('resrc') == false) {
        $thumbwidth = c::get('thumb.dev.width', 800);
    } else {
        // with resrc use maximum (original) image width
        $thumbwidth = null;
    }
    // if no crop variable is defined *and* no cropratio
    // is set, the crop variable is set to false
    if (!isset($options['crop']) && !isset($options['cropratio'])) {
        $options['crop'] = false;
    }
    // when a cropratio is set, calculate the ratio based height
    if (isset($options['cropratio'])) {
        // if resrc is enabled (and therefor $thumbwidth is not set (e.g. `null`),
        // to use max width of image!), set thumbwidth to width of original image
        if (!isset($thumbwidth)) {
            $thumbwidth = $image->width();
        }
        // if cropratio is a fraction string (e.g. 1/2), convert to decimal
        // if(!is_numeric($options['cropratio'])) {
        if (strpos($options['cropratio'], '/') !== false) {
            list($numerator, $denominator) = str::split($options['cropratio'], '/');
            $options['cropratio'] = $numerator / $denominator;
        }
        // calculate new thumb height based on cropratio
        $thumbheight = round($thumbwidth * $options['cropratio']);
        // if a cropratio is set, the crop variable is always set to true
        $options['crop'] = true;
    } else {
        $thumbheight = null;
        // max height of image
    }
    // Create thumb url (create a new thumb object)
    $options['thumburl'] = thumb($image, array('width' => $thumbwidth, 'height' => $thumbheight, 'crop' => $options['crop']), false);
    // Add image object to options array, for use in template
    $options['image'] = $image;
    // Return template HTML
    return tpl::load(__DIR__ . DS . 'template.php', $options);
}
开发者ID:igorqr,项目名称:kirby-extensions,代码行数:56,代码来源:figure.php

示例12: subpages

 public static function subpages($pages, $blueprint)
 {
     switch ($blueprint->pages()->sort()) {
         case 'flip':
             $pages = $pages->flip();
             break;
         default:
             $parts = str::split($blueprint->pages()->sort(), ' ');
             if (count($parts) > 0) {
                 $pages = call_user_func_array(array($pages, 'sortBy'), $parts);
             }
             break;
     }
     return $pages;
 }
开发者ID:madebypost,项目名称:Gulp-Neat-KirbyCMS,代码行数:15,代码来源:api.php

示例13: subpages

 public static function subpages($pages, $blueprint)
 {
     switch ($blueprint->pages()->sort()) {
         case 'flip':
             $pages = $pages->flip();
             break;
         default:
             $parts = str::split($blueprint->pages()->sort(), ' ');
             $field = a::get($parts, 0);
             $order = a::get($parts, 1);
             if ($field) {
                 $pages = $pages->sortBy($field, $order);
             }
             break;
     }
     return $pages;
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:17,代码来源:api.php

示例14: check_day

 public function check_day($calendarboard_url, $date)
 {
     $Date = str::split($date, '-');
     $year = $Date[0];
     $month = $Date[1];
     $day = $Date[2];
     $year_folder = 'year-' . $year;
     $day_folder = 'day-' . $date;
     // Check Year folder existence
     if (!site()->find($calendarboard_url . '/' . $year_folder)) {
         page($calendarboard_url)->children()->create($year_folder, 'calendar-board-year', array('title' => 'year-' . $year));
     }
     // Check Day folder existence
     if (!site()->find($calendarboard_url . '/' . $year_folder . '/' . $day_folder)) {
         page($calendarboard_url . '/' . $year_folder)->children()->create($day_folder, 'calendar-board-day', array('title' => $day . '-' . $month . '-' . $year));
     }
 }
开发者ID:molocLab,项目名称:kirby-calendar-board,代码行数:17,代码来源:calendarboard.php

示例15: launch

 public static function launch()
 {
     static::$route = static::$router->run(static::$path);
     // react on invalid routes
     if (!static::$route) {
         throw new Exception('Invalid route');
     }
     // let's find the controller and controller action
     $controllerParts = str::split(static::$route->action(), '::');
     $controllerUri = $controllerParts[0];
     $controllerAction = $controllerParts[1];
     $controllerFile = root('panel.app.controllers') . DS . strtolower(str_replace('Controller', '', $controllerUri)) . '.php';
     $controllerName = basename($controllerUri);
     // react on missing controllers
     if (!file_exists($controllerFile)) {
         throw new Exception('Invalid controller');
     }
     // load the controller
     require_once $controllerFile;
     // check for the called action
     if (!method_exists($controllerName, $controllerAction)) {
         throw new Exception('Invalid action');
     }
     // run the controller
     $controller = new $controllerName();
     try {
         // call the action and pass all arguments from the router
         $response = call(array($controller, $controllerAction), static::$route->arguments());
     } catch (Exception $e) {
         $file = root('panel.app.controllers') . DS . substr($controllerUri, 0, strpos($controllerUri, '/') + 1) . 'errors.php';
         require_once $file;
         $action = (isset(static::$route->modal) and static::$route->modal()) ? 'modal' : 'index';
         $controller = new ErrorsController();
         $response = call(array($controller, $action), array($e->getMessage()));
     }
     ob_start();
     // check for a valid response object
     if (is_a($response, 'Response')) {
         echo $response;
     } else {
         echo new Response($response);
     }
     ob_end_flush();
 }
开发者ID:kompuser,项目名称:panel,代码行数:44,代码来源:app.php


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