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


PHP Strings::replace方法代码示例

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


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

示例1: renderPairMulti

 public function renderPairMulti(array $controls)
 {
     $rendered = parent::renderPairMulti($controls);
     $class = $this->getValue('control .buttons');
     $firstReplace = Nette\Utils\Strings::replace($rendered, '~(form-group">\\s*<div) class="~', "\\0{$class} ");
     return Nette\Utils\Strings::replace($firstReplace, '~(form-group">\\s*<div)>~', "\\1 class=\"{$class}\">");
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:7,代码来源:BaseFormRenderer.php

示例2: priceCreate

 /**
  * @param double|double[] $price
  * @param null|string     $units
  * @param int             $decimalLength
  *
  * @return string|string[]
  */
 public static function priceCreate($price, $units = NULL, $decimalLength = 2)
 {
     if (is_array($price)) {
         $out = [];
         foreach ($price as $v) {
             $out[] = static::priceCreate($v, $units, $decimalLength);
         }
         return $out;
     } else {
         $workPrice = floor(abs($price * pow(10, $decimalLength)));
         $workDecimalPrice = floor(abs($price * pow(10, $decimalLength + 1)));
         $integerPrice = floor($workPrice / pow(10, $decimalLength));
         $integerLength = strlen($integerPrice);
         $decimalPrice = Nette\Utils\Strings::padLeft(round(static::numberAt($workDecimalPrice, 0, $decimalLength + 1) / 10), $decimalLength, '0');
         $integerTernary = ceil($integerLength / 3);
         $outPrice = '';
         for ($i = $integerTernary - 1; $i >= 0; $i--) {
             if ($outPrice != "") {
                 $outPrice .= '.';
             }
             $outPrice .= Nette\Utils\Strings::padLeft(static::numberAt($integerPrice, $i * 3, 3), 3, '0');
         }
         $outPrice = Nette\Utils\Strings::replace($outPrice, ['~^[0]*~' => '']);
         return ($price < 0 ? '-' : '') . $outPrice . ',' . (in_array($decimalPrice, ['', '0']) ? '-' : $decimalPrice) . (is_null($units) ? '' : ' ' . $units);
     }
 }
开发者ID:trejjam,项目名称:utils,代码行数:33,代码来源:Utils.php

示例3: formatRecordString

 public static function formatRecordString($record, $formatString)
 {
     return Strings::replace($formatString, '#%[^%]*%#u', function ($m) use($record) {
         $m = Strings::trim($m[0], '%');
         return $m != '' ? $record[$m] : "%";
     });
 }
开发者ID:hleumas,项目名称:gridito,代码行数:7,代码来源:Grid.php

示例4: computeHash

 /**
  * @param string|array $file
  * @param int $time
  * @param bool $debugMode
  *
  * @return string
  */
 public static function computeHash($file, $time, $debugMode)
 {
     $debug = $debugMode ? 1 : 0;
     $file = is_array($file) ? implode(',', $file) : $file;
     $md5Raw = md5("{$debug};{$file};{$time}", TRUE);
     $base64 = Strings::replace(base64_encode($md5Raw), '~\\W~');
     return Strings::substring(Strings::webalize($base64), 0, 8);
 }
开发者ID:sw2eu,项目名称:load-common,代码行数:15,代码来源:Helpers.php

示例5: 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

示例6: formatTemplateFiles

 /**
  * Formats view template file names.
  *
  * @param string $subMethod
  * @return array
  */
 protected function formatTemplateFiles($subMethod)
 {
     $controlName = $this->getReflection()->getShortName();
     $control = Strings::replace($controlName, '~Control$~');
     $dir = dirname($this->getReflection()->getFileName());
     $dir = is_dir("{$dir}/templates") ? $dir : dirname($dir);
     $view = $subMethod ?: 'default';
     return ["{$dir}/templates/{$control}/{$view}.latte", "{$dir}/templates/{$control}.{$view}.latte"];
 }
开发者ID:sw2eu,项目名称:latte-control,代码行数:15,代码来源:LatteControl.php

示例7: formatLikeStatementWildcards

 /**
  * Format given value for LIKE statement
  *
  * @param string $value
  * @param string $replacement
  * @return string
  */
 public static function formatLikeStatementWildcards($value, $replacement = '%')
 {
     // Escape wildcard character used in PDO
     $value = str_replace($replacement, '\\' . $replacement, $value);
     // Replace asterisks
     $value = \Nette\Utils\Strings::replace($value, '~(?!\\\\)(.?)\\*~', '\\1' . $replacement);
     // Replace escaped asterisks
     return str_replace('\\*', '*', $value);
 }
开发者ID:jurasm2,项目名称:datagrid,代码行数:16,代码来源:WildcardHelper.php

示例8: inflect

 /**
  * 
  * @param string $word
  * @param string $genus (rod)
  * @param string $number (číslo - jednotné nebo množné)
  * @param string $case (pád)
  * @return string
  */
 public function inflect($word, $genus = 'n', $number = 's', $case = 'nom')
 {
     foreach ($this->dictionary as $key => $shapes) {
         if (Strings::match($word, $key) && isset($this->dictionary[$key][$genus][$number][$case])) {
             $inflectedWord = Strings::replace($word, $key, $shapes[$genus][$number][$case]);
             return $inflectedWord;
         }
     }
     return $inflectedWord;
 }
开发者ID:MrTommy1979,项目名称:inflector,代码行数:18,代码来源:Inflector.php

示例9: __invoke

 /**
  * Invoke filter
  *
  * @param string code
  * @param WebLoader loader
  * @param string file
  * @return string
  */
 public function __invoke($code, \Lohini\WebLoader\WebLoader $loader, $file = NULL)
 {
     $regexp = '/@charset ["\']utf\\-8["\'];(\\n)?/i';
     $removed = Strings::replace($code, $regexp);
     // At least one charset was in the code
     if (Strings::length($removed) < Strings::length($code)) {
         $code = self::CHARSET . "\n" . $removed;
     }
     return $code;
 }
开发者ID:lohini,项目名称:webloader,代码行数:18,代码来源:CssCharsetFilter.php

示例10: reformatMarkdownLinks

 /**
  * @param Github $github
  */
 protected function reformatMarkdownLinks(Github $github)
 {
     $github->content = Strings::replace($github->content, '#\\[(.*)\\]\\((.+)\\)#iU', function ($matches) use($github) {
         list($all, $title, $url) = $matches;
         if (!Validators::isUrl($url)) {
             $url = $github->linker->getBlobUrl($matches[2]);
         }
         return sprintf('[%s](%s)', $title, $url);
     });
 }
开发者ID:milo,项目名称:componette.com,代码行数:13,代码来源:GenerateContentTask.php

示例11: formatColumnName

 /**
  * Formats column name.
  * @param  string
  * @return string
  */
 public function formatColumnName($key)
 {
     static $cache = array();
     $name =& $cache[$key];
     if ($name === NULL) {
         $name = Strings::replace($key, '#[A-Z]#', function ($match) {
             return '_' . strtolower($match[0]);
         });
     }
     return $name;
 }
开发者ID:fabik,项目名称:database,代码行数:16,代码来源:ActiveRow.php

示例12: doRender

 /**
  * @param string name of current render method, typically __METHOD__ (containing "ClassName::render")
  * @return void
  */
 protected function doRender($renderMethod)
 {
     $template = $this->getTemplate();
     $classFile = $this->getReflection()->getFileName();
     list(, $view) = Strings::match($renderMethod, '~::render(.*)\\z~');
     $templateFile = Strings::replace($classFile, '~(?<=/)(.+)\\.php\\z~i', function ($m) use($view) {
         return $m[1] . ($view ? ".{$view}" : '') . '.latte';
     });
     $template->setFile($templateFile);
     $template->render();
 }
开发者ID:pecinaon,项目名称:sandbox,代码行数:15,代码来源:Control.php

示例13: startup

 public function startup()
 {
     parent::startup();
     $this->template->addFilter("dicomString", function ($text) {
         return \Nette\Utils\Strings::replace($text, "/\\^/", " ");
     });
     $this->template->addFilter("dicomDate", function ($text) {
         return date("d-m-Y", strtotime($text));
     });
     return;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:11,代码来源:ViewerPresenter.php

示例14: lex

 /**
  * @param string $config
  * @return TokenIterator tokens
  * @throws ConfigException
  */
 public function lex($config)
 {
     $normalized = Strings::normalize($config);
     // remove meaningless leading spacing to simplify T_KEYWORD
     $simplified = Strings::replace($normalized, '~^\\s+~m', '');
     try {
         $tokens = $this->getTokenizer()->tokenize($simplified);
         return new TokenIterator($tokens);
     } catch (TokenizerException $e) {
         throw ConfigException::createFromLexerException($e);
     }
 }
开发者ID:Mikulas,项目名称:ssh-config,代码行数:17,代码来源:Lexer.php

示例15: expandPath

 /**
  * Expands @fooModule/path/....
  * @static
  * @param $path
  * @param array $modules
  * @return string
  * @throws InvalidArgumentException
  */
 public function expandPath($path, $localPrefix = '')
 {
     if (substr($path, 0, 1) !== '@' || ($pos = strpos($path, 'Module')) === FALSE) {
         return $path;
     }
     $module = lcfirst(substr($path, 1, $pos - 1));
     if (!isset($this->modules[$module])) {
         throw new InvalidArgumentException("Module '{$module}' does not exist.");
     }
     $path = $this->modules[$module]['path'] . ($localPrefix ? '/' . $localPrefix : '') . substr($path, $pos + 6);
     return \Nette\Utils\Strings::replace($path, '~\\\\~', '/');
 }
开发者ID:svobodni,项目名称:web,代码行数:20,代码来源:Helpers.php


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