當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。