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


PHP Strings::split方法代码示例

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


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

示例1: filter

 public function filter($phrase, $collumns)
 {
     $phrase = strtolower(Strings::toAscii($phrase));
     $this->filter = array(Strings::split($phrase, '/\\s+/'), $collumns);
     $this->data = null;
     return $this;
 }
开发者ID:hleumas,项目名称:databaza,代码行数:7,代码来源:FullTextModel.php

示例2: macroSet

 public function macroSet(MacroNode $node, PhpWriter $writer)
 {
     $parts = Strings::replace($node->args, '~(\\s*(=>|=)\\s*|\\s+)~', '~~~', 1);
     $parts = Strings::split($parts, '/~~~/');
     $variable = $parts[0];
     $rest = $parts[1];
     return $writer->write($variable . ' = %modify(' . $rest . ')');
 }
开发者ID:manGoweb,项目名称:MangoPressTemplating,代码行数:8,代码来源:MangoPressTemplatingMacroSet.php

示例3: parseBoundaryDataFromString

 /**
  * @param string $string
  * @return array
  * @throws IntervalParseErrorException
  */
 protected static function parseBoundaryDataFromString(string $string) : array
 {
     $letters = Strings::split($string, '//u', PREG_SPLIT_NO_EMPTY);
     if (count($letters) < 2) {
         throw new IntervalParseErrorException("Boundary part '{$string}' is too short. It must be at leas 2 character long. Example: '" . Boundary::STRING_OPENED_LEFT . "1' or '9" . Boundary::STRING_CLOSED_RIGHT . "'.");
     }
     return self::getElementAndStateData($letters);
 }
开发者ID:achse,项目名称:php-math-interval,代码行数:13,代码来源:IntervalStringParser.php

示例4: __construct

	/**
	 * @param string
	 * @param Request
	 */
	public function __construct($response, Request $request)
	{
		$this->request = $request;

		$headers = Strings::split(substr($response, 0, $this->request->info['header_size']), "~[\n\r]+~", PREG_SPLIT_NO_EMPTY);
		$this->parseHeaders($headers);
		$this->body = substr($response, $this->request->info['header_size']);
	}
开发者ID:norbe,项目名称:framework,代码行数:12,代码来源:Response.php

示例5: extractTags

 public function extractTags($input)
 {
     $matches = Strings::match($input, '/^\\s*(?<tag_list>\\[\\s*[\\pL\\d._-]+\\s*\\](?:\\s*(?&tag_list))?)/u');
     if ($matches) {
         $tags = Strings::trim($matches['tag_list'], '[] ');
         $tags = Strings::split($tags, '/\\]\\s*\\[/');
         $tags = array(array_map('Nette\\Utils\\Strings::webalize', $tags), $tags);
     } else {
         $tags = array();
     }
     return $tags;
 }
开发者ID:zoidbergthepopularone,项目名称:fitak,代码行数:12,代码来源:Tags.php

示例6: getValue

 /**
  * @return array
  */
 public function getValue()
 {
     // temporarily disable filters
     $filters = $this->filters;
     $this->filters = array();
     $res = Strings::split(parent::getValue(), "" . $this->delimiter . "");
     $this->filters = $filters;
     foreach ($res as &$tag) {
         foreach ($this->filters as $filter) {
             $tag = $filter($tag);
         }
         if (!$tag) {
             unset($tag);
         }
     }
     return $res;
 }
开发者ID:svobodni,项目名称:web,代码行数:20,代码来源:TagsInput.php

示例7: parseQuery

 /**
  * Parse search query.
  *
  * @param  string
  * @return array associative array with keys 'query' and 'tags'
  */
 public function parseQuery($input)
 {
     // normalize input
     $input = Strings::lower(Strings::trim($input));
     $input = Strings::replace($input, '/\\s+/', ' ');
     // extract tags
     $matches = Strings::matchAll($input, '/(?<=^|\\s)tag:\\s*(?<tag_list>[\\pL\\d_-]+(?:\\s*,\\s*(?&tag_list))?)/u');
     $tags = array();
     $query = $input;
     foreach ($matches as $m) {
         $tmp = Strings::split($m['tag_list'], '/\\s*,\\s*/');
         $tmp = array_map('Nette\\Utils\\Strings::webalize', $tmp);
         $tmp = array_unique($tmp);
         $tags = array_merge($tags, $tmp);
         $query = str_replace($m[0], '', $query);
     }
     $query = Strings::trim($query) ?: null;
     return array('query' => $query, 'tags' => $tags);
 }
开发者ID:zoidbergthepopularone,项目名称:fitak,代码行数:25,代码来源:SearchQueryParser.php

示例8: underscoreToCamelWithoutPrefix

 /**
  * @param string $string
  * @param string $reference
  * @return string
  */
 public static function underscoreToCamelWithoutPrefix($string, $reference)
 {
     // Find longest common prefix between $referencingColumn and (this) $tableName
     $referenceWords = Strings::split($reference, '#_#');
     $stringWords = Strings::split($string, '#_#');
     $remainingWords = $stringWords;
     for ($i = 0; $i < count($stringWords) && $i < count($referenceWords) && count($remainingWords) > 1; $i++) {
         if ($referenceWords[$i] == $stringWords[$i]) {
             array_shift($remainingWords);
         } else {
             break;
         }
     }
     if (count($remainingWords) > 0) {
         $result = '';
         foreach ($remainingWords as $word) {
             Strings::firstUpper($word);
             $result .= Strings::firstUpper($word);
         }
         return $result;
     }
     return self::underscoreToCamel($string);
 }
开发者ID:filsedla,项目名称:hyperrow,代码行数:28,代码来源:Helpers.php

示例9: renderDefault

 public function renderDefault($search)
 {
     //FIXME tagy ::: 'publish_date <=' => new \DateTime()
     $string = Strings::lower(Strings::normalize($search));
     $string = Strings::replace($string, '/[^\\d\\w]/u', ' ');
     $words = Strings::split(Strings::trim($string), '/\\s+/u');
     $words = array_unique(array_filter($words, function ($word) {
         return Strings::length($word) > 1;
     }));
     $words = array_map(function ($word) {
         return Strings::toAscii($word);
     }, $words);
     $string = implode(' ', $words);
     $this->template->tag = $this->tags->findOneBy(['name' => $string]);
     $result = $this->posts->fulltextSearch($string);
     if (count($result) == 0) {
         $this->template->search = $search;
         $this->template->error = 'Nic nebylo nalezeno';
     } else {
         $this->template->search = $search;
         $this->template->result = $result;
     }
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:23,代码来源:SearchPresenter.php

示例10: tokenize

 /**
  * Tokenize string.
  * @param  string
  * @return array
  */
 public function tokenize($input)
 {
     if ($this->types) {
         $tokens = Strings::matchAll($input, $this->re);
         $len = 0;
         $count = count($this->types);
         foreach ($tokens as &$match) {
             $type = NULL;
             for ($i = 1; $i <= $count; $i++) {
                 if (!isset($match[$i])) {
                     break;
                 } elseif ($match[$i] != NULL) {
                     $type = $this->types[$i - 1];
                     break;
                 }
             }
             $match = array(self::VALUE => $match[0], self::OFFSET => $len, self::TYPE => $type);
             $len += strlen($match[self::VALUE]);
         }
         if ($len !== strlen($input)) {
             $errorOffset = $len;
         }
     } else {
         $tokens = Strings::split($input, $this->re, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
         $last = end($tokens);
         if ($tokens && !Strings::match($last[0], $this->re)) {
             $errorOffset = $last[1];
         }
     }
     if (isset($errorOffset)) {
         list($line, $col) = $this->getCoordinates($input, $errorOffset);
         $token = str_replace("\n", '\\n', substr($input, $errorOffset, 10));
         throw new TokenizerException("Unexpected '{$token}' on line {$line}, column {$col}.");
     }
     return $tokens;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:41,代码来源:Tokenizer.php

示例11: getCliOptionName

 /**
  * Converts 'optionName' to 'option-name', i.e. from property convention to CLI convention
  *
  * @param string $propertyName
  * @return string
  */
 public static function getCliOptionName($propertyName)
 {
     $words = Strings::split($propertyName, '/(?=[A-Z])/');
     return strtolower(join("-", $words));
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:11,代码来源:OptionsConventionConverter.php

示例12: setMask

 /**
  * Parse mask and array of default values; initializes object.
  * @param  string
  * @param  array
  * @return void
  */
 private function setMask($mask, array $metadata)
 {
     $this->mask = $mask;
     // detect '//host/path' vs. '/abs. path' vs. 'relative path'
     if (preg_match('#(?:(https?):)?(//.*)#A', $mask, $m)) {
         $this->type = self::HOST;
         list(, $this->scheme, $mask) = $m;
     } elseif (substr($mask, 0, 1) === '/') {
         $this->type = self::PATH;
     } else {
         $this->type = self::RELATIVE;
     }
     foreach ($metadata as $name => $meta) {
         if (!is_array($meta)) {
             $metadata[$name] = $meta = [self::VALUE => $meta];
         }
         if (array_key_exists(self::VALUE, $meta)) {
             if (is_scalar($meta[self::VALUE])) {
                 $metadata[$name][self::VALUE] = (string) $meta[self::VALUE];
             }
             $metadata[$name]['fixity'] = self::CONSTANT;
         }
     }
     if (strpbrk($mask, '?<>[]') === FALSE) {
         $this->re = '#' . preg_quote($mask, '#') . '/?\\z#A';
         $this->sequence = [$mask];
         $this->metadata = $metadata;
         return;
     }
     // PARSE MASK
     // <parameter-name[=default] [pattern]> or [ or ] or ?...
     $parts = Strings::split($mask, '/<([^<>= ]+)(=[^<> ]*)? *([^<>]*)>|(\\[!?|\\]|\\s*\\?.*)/');
     $this->xlat = [];
     $i = count($parts) - 1;
     // PARSE QUERY PART OF MASK
     if (isset($parts[$i - 1]) && substr(ltrim($parts[$i - 1]), 0, 1) === '?') {
         // name=<parameter-name [pattern]>
         $matches = Strings::matchAll($parts[$i - 1], '/(?:([a-zA-Z0-9_.-]+)=)?<([^> ]+) *([^>]*)>/');
         foreach ($matches as list(, $param, $name, $pattern)) {
             // $pattern is not used
             if (isset(static::$styles['?' . $name])) {
                 $meta = static::$styles['?' . $name];
             } else {
                 $meta = static::$styles['?#'];
             }
             if (isset($metadata[$name])) {
                 $meta = $metadata[$name] + $meta;
             }
             if (array_key_exists(self::VALUE, $meta)) {
                 $meta['fixity'] = self::OPTIONAL;
             }
             unset($meta['pattern']);
             $meta['filterTable2'] = empty($meta[self::FILTER_TABLE]) ? NULL : array_flip($meta[self::FILTER_TABLE]);
             $metadata[$name] = $meta;
             if ($param !== '') {
                 $this->xlat[$name] = $param;
             }
         }
         $i -= 5;
     }
     // PARSE PATH PART OF MASK
     $brackets = 0;
     // optional level
     $re = '';
     $sequence = [];
     $autoOptional = TRUE;
     $aliases = [];
     do {
         $part = $parts[$i];
         // part of path
         if (strpbrk($part, '<>') !== FALSE) {
             throw new Nette\InvalidArgumentException("Unexpected '{$part}' in mask '{$mask}'.");
         }
         array_unshift($sequence, $part);
         $re = preg_quote($part, '#') . $re;
         if ($i === 0) {
             break;
         }
         $i--;
         $part = $parts[$i];
         // [ or ]
         if ($part === '[' || $part === ']' || $part === '[!') {
             $brackets += $part[0] === '[' ? -1 : 1;
             if ($brackets < 0) {
                 throw new Nette\InvalidArgumentException("Unexpected '{$part}' in mask '{$mask}'.");
             }
             array_unshift($sequence, $part);
             $re = ($part[0] === '[' ? '(?:' : ')?') . $re;
             $i -= 4;
             continue;
         }
         $pattern = trim($parts[$i]);
         $i--;
         // validation condition (as regexp)
//.........这里部分代码省略.........
开发者ID:nette,项目名称:application,代码行数:101,代码来源:Route.php

示例13: setMask

 protected function setMask($mask)
 {
     $this->mask = $mask;
     $metadata = array();
     // PARSE MASK
     // <parameter-name[=default] [pattern] [#class]> or [ or ] or ?...
     $parts = Strings::split($mask, '/<([^># ]+)() *([^>#]*)(#?[^>\\[\\]]*)>|(\\[!?|\\]|\\s*\\?.*)/');
     $i = count($parts) - 1;
     // PARSE PATH PART OF MASK
     $brackets = 0;
     // optional level
     $re = '';
     $sequence = array();
     $autoOptional = TRUE;
     do {
         array_unshift($sequence, $parts[$i]);
         $re = preg_quote($parts[$i], '#') . $re;
         if ($i === 0) {
             break;
         }
         $i--;
         $part = $parts[$i];
         // [ or ]
         if ($part === '[' || $part === ']' || $part === '[!') {
             $brackets += $part[0] === '[' ? -1 : 1;
             if ($brackets < 0) {
                 throw new Nette\InvalidArgumentException("Unexpected '{$part}' in mask '{$mask}'.");
             }
             array_unshift($sequence, $part);
             $re = ($part[0] === '[' ? '(?:' : ')?') . $re;
             $i -= 5;
             continue;
         }
         $class = $parts[$i];
         $i--;
         // validation class
         $pattern = trim($parts[$i]);
         $i--;
         // validation condition (as regexp)
         $default = $parts[$i];
         $i--;
         // default value
         $name = $parts[$i];
         $i--;
         // parameter name
         array_unshift($sequence, $name);
         if ($name[0] === '?') {
             // "foo" parameter
             $name = substr($name, 1);
             $re = $pattern ? '(?:' . preg_quote($name, '#') . "|{$pattern}){$re}" : preg_quote($name, '#') . $re;
             $sequence[1] = $name . $sequence[1];
             continue;
         }
         // check name (limitation by regexp)
         if (preg_match('#[^a-z0-9_-]#i', $name)) {
             throw new Nette\InvalidArgumentException("Parameter name must be alphanumeric string due to limitations of PCRE, '{$name}' given.");
         }
         // pattern, condition & metadata
         if ($class !== '') {
             if (!isset(static::$styles[$class])) {
                 throw new Nette\InvalidStateException("Parameter '{$name}' has '{$class}' flag, but Route::\$styles['{$class}'] is not set.");
             }
             $meta = static::$styles[$class];
         } elseif (isset(static::$styles[$name])) {
             $meta = static::$styles[$name];
         } else {
             $meta = static::$styles['#'];
         }
         if (isset($metadata[$name])) {
             $meta = $metadata[$name] + $meta;
         }
         if ($pattern == '' && isset($meta[self::PATTERN])) {
             $pattern = $meta[self::PATTERN];
         }
         $meta[self::PATTERN] = "#(?:{$pattern})\\z#A" . ($this->flags & self::CASE_SENSITIVE ? '' : 'iu');
         // include in expression
         $re = '(?P<' . str_replace('-', '___', $name) . '>(?U)' . $pattern . ')' . $re;
         // str_replace is dirty trick to enable '-' in parameter name
         if ($brackets) {
             // is in brackets?
             if (!isset($meta[self::VALUE])) {
                 $meta[self::VALUE] = $meta['defOut'] = NULL;
             }
             $meta['fixity'] = self::PATH_OPTIONAL;
         } elseif (!$autoOptional) {
             unset($meta['fixity']);
         } elseif (isset($meta['fixity'])) {
             // auto-optional
             $re = '(?:' . $re . ')?';
             $meta['fixity'] = self::PATH_OPTIONAL;
         } else {
             $autoOptional = FALSE;
         }
         $metadata[$name] = $meta;
     } while (TRUE);
     if ($brackets) {
         throw new Nette\InvalidArgumentException("Missing closing ']' in mask '{$mask}'.");
     }
     $this->re = '#' . $re . '/?\\z#A' . ($this->flags & self::CASE_SENSITIVE ? '' : 'iu');
     $this->metadata = $metadata;
//.........这里部分代码省略.........
开发者ID:vbuilder,项目名称:framework,代码行数:101,代码来源:ResourceUrlMatcher.php

示例14: parseFile

 /**
  * Fix downloaded file
  * @throws \Curl\CurlException
  * @throws \InvalidStateException
  * @return \Curl\Response
  */
 private function parseFile()
 {
     if ($this->request->method === Request::DOWNLOAD) {
         $path_p = $this->request->downloadPath;
         @fclose($this->request->getOption('file'));
         // internationaly @
         if (($fp = @fopen($this->request->fileProtocol . '://' . $path_p, "rb")) === FALSE) {
             // internationaly @
             throw new \InvalidStateException("Fopen error for file '{$path_p}'");
         }
         $headers = Strings::split(@fread($fp, $this->request->info['header_size']), "~[\n\r]+~", PREG_SPLIT_NO_EMPTY);
         // internationaly @
         $this->Headers = array_merge($this->Headers, static::parseHeaders($headers));
         @fseek($fp, $this->request->info['header_size']);
         // internationaly @
         $path_t = $this->request->downloadPath . '.tmp';
         if (($ft = @fopen($this->request->fileProtocol . '://' . $path_t, "wb")) === FALSE) {
             // internationaly @
             throw new \InvalidStateException("Write error for file '{$path_t}' ");
         }
         while (!feof($fp)) {
             $row = fgets($fp, 4096);
             fwrite($ft, $row);
         }
         @fclose($fp);
         // internationaly @
         @fclose($ft);
         // internationaly @
         if (!@unlink($this->request->fileProtocol . '://' . $path_p)) {
             // internationaly @
             throw new \InvalidStateException("Error while deleting file {$path_p} ");
         }
         if (!@rename($path_t, $path_p)) {
             // internationaly @
             throw new \InvalidStateException("Error while renaming file '{$path_t}' to '" . basename($path_p) . "'. ");
         }
         chmod($path_p, 0755);
         if (!$this->Headers) {
             throw new CurlException("Headers parsing failed", NULL, $this);
         }
     }
     return $this;
 }
开发者ID:norbe,项目名称:cURL-wrapper,代码行数:49,代码来源:Response.php

示例15: getOffset

 /**
  * Returns position of token in input string.
  * @param  int token number
  * @return array [offset, line, column]
  */
 public function getOffset($i)
 {
     $tokens = Strings::split($this->input, $this->re, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
     $offset = isset($tokens[$i]) ? $tokens[$i][1] : strlen($this->input);
     return array($offset, $offset ? substr_count($this->input, "\n", 0, $offset) + 1 : 1, $offset - strrpos(substr($this->input, 0, $offset), "\n"));
 }
开发者ID:exesek,项目名称:nette20login,代码行数:11,代码来源:Tokenizer.php


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