當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Regex::replace方法代碼示例

本文整理匯總了PHP中Regex::replace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Regex::replace方法的具體用法?PHP Regex::replace怎麽用?PHP Regex::replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Regex的用法示例。


在下文中一共展示了Regex::replace方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: word

 public function word($string = '', $badWords = '', $changeChar = '[badwords]')
 {
     if (!isValue($string)) {
         return Error::set(lang('Error', 'valueParameter', 'string'));
     }
     if (!is_array($badWords)) {
         if (empty($badWords)) {
             return $string;
         }
         return $string = Regex::replace($badWords, $changeChar, $string, 'xi');
     }
     $ch = '';
     $i = 0;
     if (!empty($badWords)) {
         foreach ($badWords as $value) {
             if (!is_array($changeChar)) {
                 $ch = $changeChar;
             } else {
                 if (isset($changeChar[$i])) {
                     $ch = $changeChar[$i];
                     $i++;
                 }
             }
             $string = Regex::replace($value, $ch, $string, 'xi');
         }
     }
     return $string;
 }
開發者ID:Allopa,項目名稱:ZN-Framework-Starter,代碼行數:28,代碼來源:Filter.php

示例2: ncEncode

 public function ncEncode($string = '', $badWords = '', $changeChar = '[badchars]')
 {
     if (!is_string($string)) {
         return Error::set(lang('Error', 'stringParameter', 'string'));
     }
     // 2. Parametre boş ise varsayılan olarak Config/Security.php dosya ayarlarını kullan.
     if (empty($badWords)) {
         $secnc = $this->config['ncEncode'];
         $badWords = $secnc['bad_chars'];
         $changeChar = $secnc['change_bad_chars'];
     }
     if (!is_array($badWords)) {
         return $string = Regex::replace($badWords, $changeChar, $string, 'xi');
     }
     $ch = '';
     $i = 0;
     foreach ($badWords as $value) {
         if (!is_array($changeChar)) {
             $ch = $changeChar;
         } else {
             if (isset($changeChar[$i])) {
                 $ch = $changeChar[$i];
                 $i++;
             }
         }
         $string = Regex::replace($value, $ch, $string, 'xi');
     }
     return $string;
 }
開發者ID:Allopa,項目名稱:ZN-Framework-Starter,代碼行數:29,代碼來源:Security.php

示例3: internalRouteURI

function internalRouteURI(string $requestUri = '') : string
{
    $config = Config::get('Services', 'route');
    if ($config['openPage']) {
        $internalDir = NULL;
        if (defined('_CURRENT_PROJECT')) {
            $configAppdir = PROJECTS_CONFIG['directory']['others'];
            if (is_array($configAppdir)) {
                $internalDir = !empty($configAppdir[$requestUri]) ? $requestUri : _CURRENT_PROJECT;
            } else {
                $internalDir = _CURRENT_PROJECT;
            }
        }
        if ($requestUri === DIRECTORY_INDEX || $requestUri === getLang() || $requestUri === $internalDir || empty($requestUri)) {
            $requestUri = $config['openPage'];
        }
    }
    $uriChange = $config['changeUri'];
    $patternType = $config['patternType'];
    if (!empty($uriChange)) {
        foreach ($uriChange as $key => $val) {
            if ($patternType === 'classic') {
                $requestUri = preg_replace(presuffix($key) . 'xi', $val, $requestUri);
            } else {
                $requestUri = Regex::replace($key, $val, $requestUri, 'xi');
            }
        }
    }
    return $requestUri;
}
開發者ID:znframework,項目名稱:znframework,代碼行數:30,代碼來源:Internal.php

示例4: getController

 private static function getController($location)
 {
     $location = strtolower($location);
     $pattern = '/controller/';
     $match = Regex::match($pattern, $location);
     if ($match > 0) {
         $location = Regex::replace($pattern, '', $location);
     }
     return $location;
 }
開發者ID:anzasolutions,項目名稱:simlandia,代碼行數:10,代碼來源:navigator.class.php

示例5: find

 /**
  * @Invocable
  */
 protected function find()
 {
     if ($this->request->hasKey('friend')) {
         $name = Regex::replace('/[^A-Za-z0-9]/', '', $this->request->valueOf('friend'));
         Navigator::redirectTo($this->url->getParametersPath($name));
     }
     $name = $this->url->getParameter(0);
     if ($name == null) {
         return;
     }
     $this->getUsers($name);
 }
開發者ID:anzasolutions,項目名稱:simlandia,代碼行數:15,代碼來源:friendscontroller.class.php

示例6: routeUri

function routeUri($requestUri = '')
{
    if (Config::get('Route', 'openPage')) {
        if ($requestUri === 'index.php' || empty($requestUri) || $requestUri === getLang()) {
            $requestUri = Config::get('Route', 'openPage');
        }
    }
    $config = Config::get('Route');
    $uriChange = $config['changeUri'];
    $patternType = $config['patternType'];
    if (!empty($uriChange)) {
        foreach ($uriChange as $key => $val) {
            if ($patternType === 'classic') {
                $requestUri = preg_replace(presuffix($key) . 'xi', $val, $requestUri);
            } else {
                $requestUri = Regex::replace($key, $val, $requestUri, 'xi');
            }
        }
    }
    return $requestUri;
}
開發者ID:bytemtek,項目名稱:znframework,代碼行數:21,代碼來源:Functions.php


注:本文中的Regex::replace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。