本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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/'));
}
示例5: value
public function value()
{
$value = InputListField::value();
if (is_array($value)) {
return $value;
} else {
return str::split($value, ',');
}
}
示例6: value
public function value()
{
$value = parent::value();
if (is_array($value)) {
return $value;
} else {
return str::split($value, ',');
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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));
}
}
示例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();
}