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


PHP mb_split函数代码示例

本文整理汇总了PHP中mb_split函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_split函数的具体用法?PHP mb_split怎么用?PHP mb_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: filter

 /**
  * Defined by Zend_Filter_Interface
  *
  * Returns $value translitered to ASCII
  *
  * @param  string $value
  * @return string
  */
 public function filter($value)
 {
     //translitere specific chars
     $value = $this->_transliterateCzech($value);
     $value = $this->_transliterateSlovak($value);
     $value = $this->_transliterateRussian($value);
     $value = $this->_transliterateGerman($value);
     $value = $this->_transliterateFrench($value);
     $value = $this->_transliterateHungarian($value);
     $value = $this->_transliteratePolish($value);
     $value = $this->_transliterateDanish($value);
     $value = $this->_transliterateCroatian($value);
     //split string to single characters
     $characters = mb_split("~(.)~", $value);
     $return = '';
     foreach ($characters as $character) {
         /*  maybe should contain also //IGNORE  */
         $converted = iconv("utf-8", "ASCII//TRANSLIT", $character);
         //if character was converted, strip out wrong marks
         if ($character !== $converted) {
             $return .= preg_replace('~["\'^]+~', '', $converted);
         } else {
             $return .= $converted;
         }
     }
     return $return;
 }
开发者ID:arnaud-hours,项目名称:PlaygroundCore,代码行数:35,代码来源:Transliteration.php

示例2: unmarkedText

 /**
  * Inject span tags for each line to indicate direction.
  *
  * @param  string  $text  Single line's worth of text.
  * @return string
  */
 protected function unmarkedText($text)
 {
     $newText = "";
     if ($this->breaksEnabled) {
         $parts = mb_split('[ ]*\\n', $text);
     } else {
         $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\\n', $text);
     }
     foreach ($parts as $index => &$part) {
         if ($index > 0) {
             $newText .= "<br />\n";
         }
         // Remove trailing spaces.
         $part = mb_ereg_replace('/[ ]*\\n/', "\n", $part);
         // Determine directon
         $ltr = $this->getLtrStrLen($part);
         $rtl = $this->getRtlStrLen($part);
         $dir = null;
         if ($this->isLtr() && $rtl > 0 && $rtl > $ltr) {
             $dir = "rtl";
         } else {
             if ($this->isRtl() && $ltr > 0 && $ltr > $rtl) {
                 $dir = "ltr";
             }
         }
         if (!is_null($dir)) {
             $newText .= "<div dir=\"{$dir}\">{$part}</div>";
         } else {
             $newText .= $part;
         }
     }
     return $newText;
 }
开发者ID:infinity-next,项目名称:eightdown,代码行数:39,代码来源:ParsedownDirectional.php

示例3: CheckThrottle

function CheckThrottle()
{
    global $opt, $tpl;
    $ip_string = $_SERVER['REMOTE_ADDR'];
    $ip_blocks = mb_split('\\.', $ip_string);
    $ip_numeric = $ip_blocks[3] + $ip_blocks[2] * 256 + $ip_blocks[1] * 65536 + $ip_blocks[0] * 16777216;
    sql('CREATE TABLE IF NOT EXISTS &tmpdb.`sys_accesslog`
        (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `ip` INT UNSIGNED NOT NULL,
         `access_time` TIMESTAMP NOT NULL, INDEX (`access_time`), INDEX (`ip`)) ENGINE = MEMORY');
    $rsStaus = sql("SHOW STATUS LIKE 'Threads_connected'");
    $rStatus = sql_fetch_array($rsStaus);
    sql_free_result($rsStaus);
    if ($rStatus) {
        if ($rStatus[1] > $opt['db']['throttle_connection_count']) {
            $access_count = sql_value("SELECT COUNT(*) FROM &tmpdb.`sys_accesslog` WHERE ip ='&1'", 0, $ip_numeric);
            if ($access_count > $opt['db']['throttle_access_count']) {
                $tpl->error(ERROR_THROOTLE);
            }
        }
    }
    // remove old entries every 100st call
    if (mt_rand(0, 100) == 50) {
        sql("DELETE FROM &tmpdb.`sys_accesslog` WHERE `access_time`<CURRENT_TIMESTAMP()-'&2'", $ip_numeric, $opt['db']['throttle_access_time']);
    }
    sql("INSERT INTO &tmpdb.`sys_accesslog` (`ip`, `access_time`) VALUES ('&1', CURRENT_TIMESTAMP())", $ip_numeric);
}
开发者ID:kratenko,项目名称:oc-server3,代码行数:26,代码来源:throttle.inc.php

示例4: get_alphabet

 protected static function get_alphabet()
 {
     if (!empty(self::$alphabet)) {
         return;
     }
     /* translators: List the aphabet of your language in the order that your language prefers. list as groups of identical meanings but different characters together, e.g. in English we group A with a because they are both the same letter but different character-code. Each character group should be followed by a comma separating it from the next group. Any amount of characters per group are acceptible, and there is no requirement for all the groups to contain the same amount of characters as all the others. Be careful with the character you place first in each group as that will be used as the identifier for the group which gets displayed on the page, e.g. in English a group definition of "Aa" will indicate that we display all the posts in the group, i.e. whose titles begin with either "A" or "a", listed under a heading of "A" (the first character in the definition). */
     $alphabet = apply_filters('a-z-listing-alphabet', __('AÁÀÄÂaáàäâ,Bb,Cc,Dd,EÉÈËÊeéèëê,Ff,Gg,Hh,IÍÌÏÎiíìïî,Jj,Kk,Ll,Mm,Nn,OÓÒÖÔoóòöô,Pp,Qq,Rr,Ssß,Tt,UÚÙÜÛuúùüû,Vv,Ww,Xx,Yy,Zz'));
     /* translators: This should be a single character to denote "all entries that didn't fit under one of the alphabet character groups defined". This is used in English to categorise posts whose title begins with a numeric (0 through to 9), or some other character that is not a standard English alphabet letter. */
     $others = apply_filters('a-z-listing-non-alpha-char', __('#', 'a-z-listing'));
     $alphabet_groups = mb_split(',', $alphabet);
     $letters = array_reduce($alphabet_groups, function ($return, $group) {
         $group = A_Z_Listing::mb_string_to_array($group);
         $group_index_character = $group[0];
         $group = array_reduce($group, function ($group, $character) use($group_index_character) {
             $group[$character] = $group_index_character;
             return $group;
         });
         if (!is_array($return)) {
             return $group;
         }
         return array_merge($return, $group);
     });
     self::$alphabet = $letters;
     self::$unknown_letters = $others;
 }
开发者ID:diddledan,项目名称:wp-a-z-listing,代码行数:25,代码来源:az-listing.php

示例5: detect

 public static function detect($string)
 {
     $string = mb_strtolower($string, "UTF-8");
     // make it lowercase
     $matchWords = mb_split(" ", $string);
     array_walk($matchWords, 'trim');
     foreach ($matchWords as $key => $item) {
         if ($item == '' || strlen($item) <= 6) {
             unset($matchWords[$key]);
         }
     }
     $wordCountArr = array();
     if (is_array($matchWords)) {
         foreach ($matchWords as $key => $val) {
             $val = mb_strtolower($val, "UTF-8");
             if (isset($wordCountArr[$val])) {
                 $wordCountArr[$val]++;
             } else {
                 $wordCountArr[$val] = 1;
             }
         }
     }
     arsort($wordCountArr);
     $wordCountArr = array_slice($wordCountArr, 0, 10);
     $returnArr = array();
     foreach ($wordCountArr as $word => $count) {
         if ($count > 3) {
             $returnArr[] = $word;
         }
     }
     return $returnArr;
 }
开发者ID:iryska,项目名称:nagginua,代码行数:32,代码来源:KeywordDetector.php

示例6: split

 public function split($string = '', $pattern = '', $limit = -1)
 {
     if (!is_string($string) || !is_string($pattern)) {
         return Error::set('Error', 'stringParameter', '1.(string) & 2.(pattern)');
     }
     return mb_split($pattern, $string, $limit);
 }
开发者ID:bytemtek,项目名称:znframework,代码行数:7,代码来源:MB.php

示例7: __construct

 /**
  * accept the request or CLI parameters
  * @param string $pty request data priority:
  *                                    J - json
  *                                    P - post
  *                                    G - get
  */
 public function __construct($pty = 'JPG')
 {
     global $argc, $argv;
     if (empty($argc)) {
         // request parameters
         $jsn = @json_decode(file_get_contents('php://input'), true);
         // check for json body
         if (is_array($jsn)) {
             $this->jsn = $jsn;
             // json request
         } else {
             $this->jsn = isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'json') !== false ? array() : false;
             // empty json body?
             $jsn = array();
             // no json data
         }
         $this->Merge(array('J' => $jsn, 'P' => $_POST, 'G' => $_GET), strtoupper($pty));
         // save
     } else {
         // CLI arguments
         for ($i = 1; $i < $argc; $i++) {
             // loop the arguments
             $arg = mb_split('=', $argv[$i]);
             // split to key/value
             $this->rqt[$arg[0]] = $arg[1];
             // save
         }
     }
 }
开发者ID:hareko,项目名称:php-parameters-options-handler,代码行数:36,代码来源:ParmOpts.php

示例8: parse

 /**
  * Parse title of the question by
  * tokenizing it
  * Overrides parent's parse and users mb_split
  * instead of preg_split to be UTF-8 Safe
  * because title can be a UTF-8 string
  *
  * @return array tokens;
  */
 public function parse()
 {
     if (empty($this->origString)) {
         d('string was empty, returning empty array');
         return array();
     }
     \mb_regex_encoding('UTF-8');
     $aTokens = \mb_split('([\\s,;\\"\\?]+)', $this->origString);
     $aTokens = \array_unique($aTokens);
     $aStopwords = getStopwords();
     \array_walk($aTokens, function (&$val) use($aStopwords) {
         $val = \trim($val);
         $val = strlen($val) > 1 && !in_array($val, $aStopwords) ? $val : false;
     });
     /**
      * Remove empty values
      *
      */
     $aTokens = \array_filter($aTokens);
     /**
      * Call array_values to reindex from 0
      * otherwise if filter removed some
      * elements then Mongo will not
      * treat this as normal array
      */
     return \array_values($aTokens);
 }
开发者ID:codigoirreverente,项目名称:LampCMS,代码行数:36,代码来源:TitleTokenizer.php

示例9: update_server

/**
 * @param announcement  Server announcement string. UTF-8 assumed.
 * @param addr          Remote server address.
 */
function update_server($announcement, $addr)
{
    mb_regex_encoding('UTF-8');
    mb_internal_encoding('UTF-8');
    // First we must determine if the announcement is valid.
    $lines = mb_split("\r\n|\n|\r", $announcement);
    $info = new ServerInfo();
    while (list($line_number, $line) = each($lines)) {
        // Separate the label from the value.
        $colon = strpos($line, ":");
        // It must exist near the beginning.
        if ($colon === false || $colon >= 16) {
            continue;
        }
        $label = substr($line, 0, $colon);
        $value = substr($line, $colon + 1, strlen($line) - $colon - 1);
        if (strlen($value) >= 128) {
            continue;
        }
        // Ensure the label identifies a known property.
        if (isset($info[$label])) {
            // This will be included in the datafile.
            $info[$label] = $value;
        }
    }
    // Also include the remote address.
    $info['at'] = $addr;
    $info['time'] = time();
    // Let's write this info into the datafile.
    write_server($info);
}
开发者ID:laszloekovacs,项目名称:Doomsday-Engine,代码行数:35,代码来源:master.php

示例10: do_url

 function do_url()
 {
     $page = $this->getcurrentPage();
     if ($page->isexist()) {
         $html = convert_Page($page);
         if (keys_exists(Vars::$get, 'word', 'type')) {
             $list = mb_split('[\\s ]', Vars::$get['word']);
             $smarty = $this->getSmarty();
             $smarty->assign('word', $list);
             $smarty->assign('type', Vars::$get['type']);
             $smarty->assign('body', Search::getinstance()->mark($html, $list, Vars::$get['type']));
             $html = $smarty->fetch('highlight.tpl.htm');
         }
         $ret['body'] = $html;
         $ret['title'] = $page->getpagename();
         $ret['pagename'] = $page->getpagename();
         $ret['lastmodified'] = $page->gettimestamp();
     } else {
         $smarty = $this->getSmarty();
         $smarty->assign('pagename', $page->getpagename());
         $ret['body'] = $smarty->fetch('notexist.tpl.htm');
         $ret['title'] = $page->getpagename() . ' は存在しません';
         $ret['pagename'] = $page->getpagename();
     }
     return $ret;
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:26,代码来源:show.inc.php

示例11: load

 function load($lang)
 {
     $col = $this->languages[$lang];
     if (!$col) {
         $col = 1;
     }
     $this->messages = array();
     $path = CONF_DIR . 'messages/common.csv';
     $fin = fopen($path, 'r');
     while ($line = fgets($fin)) {
         $line = rtrim($line);
         if ($line[0] == "#") {
             continue;
         }
         $cells = mb_split(';', $line);
         if (count($cells) <= 1) {
             continue;
         }
         $key = trim($cells[0]);
         $value = $cells[$col];
         if (!$value) {
             continue;
         }
         $this->messages[$key] = $value;
     }
     fclose($fin);
 }
开发者ID:hidetobara,项目名称:voices,代码行数:27,代码来源:CommonMessages.php

示例12: wordwrapFilter

 public function wordwrapFilter($value, $length = 60, $separator = "\n", $preserve = false)
 {
     $lines = array();
     $value = str_replace("<p>", "", $value);
     $value = str_replace("</p>", "\n\n", $value);
     $value = preg_replace("/<br\\W*?\\/>/", "\n", $value);
     if (substr($value, -2) == "\n\n") {
         $value = substr($value, 0, -2);
     }
     $previous = mb_regex_encoding();
     mb_regex_encoding(craft()->templates->getTwig()->getCharset());
     $pieces = mb_split($separator, $value);
     mb_regex_encoding($previous);
     foreach ($pieces as $piece) {
         while (!$preserve && mb_strlen($piece, craft()->templates->getTwig()->getCharset()) > $length) {
             $count = count($lines);
             $lines[] = mb_substr($piece, 0, $length, craft()->templates->getTwig()->getCharset());
             $lastSpacePosition = strrpos($lines[$count], ' ', 0);
             $finalCharacters = trim(substr($lines[$count], $lastSpacePosition, 60));
             $lines[$count] = substr($lines[$count], 0, $lastSpacePosition);
             $piece = $finalCharacters . $piece;
             $piece = mb_substr($piece, $length, 2048, craft()->templates->getTwig()->getCharset());
         }
         $lines[] = $piece;
     }
     return implode($separator, $lines);
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:27,代码来源:SproutEmailTwigExtension.php

示例13: getLastGames

 public static function getLastGames($count = 5)
 {
     $var = Yii::app()->redis->getClient()->get("lastGames");
     if (!$var) {
         return [];
     }
     $varArr = mb_split(":", $var);
     $out = [];
     foreach ($varArr as $item) {
         $t = mb_split("\\|", $item);
         $tmp = ["time" => $t[0], "gameId" => $t[1], "gameLink" => Yii::app()->createUrl("/stats/" . Yii::app()->params['gameTypes'][$t[2]]["url"] . "/view", ["id" => $t[1]]), "type" => $t[2], "typeLink" => Yii::app()->createUrl("/stats/" . Yii::app()->params['gameTypes'][$t[2]]["url"] . "/list"), "typeName" => Yii::app()->params['gameTypes'][$t[2]]["name"]];
         if (Yii::app()->params['gameTypes'][$t[2]]["isTeams"]) {
             $tmp['winner'] = Yii::app()->params['gameTypes'][$t[2]]["teams"][$t[3]] . " команда выиграла ";
         } else {
             $tmp['winner'] = Users::model()->getUsernameWithAvatarAndLink($t[3], 15) . " выиграл";
         }
         $out[] = $tmp;
     }
     $out = array_reverse($out);
     $out1 = [];
     $i = 1;
     foreach ($out as $item) {
         if ($i <= $count) {
             $out1[] = $item;
         } else {
             break;
         }
         $i++;
     }
     return $out1;
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:31,代码来源:AllGames.php

示例14: wordsearch

 protected function wordsearch()
 {
     if (!isset(Vars::$get['andor']) || !isset(Vars::$get['type'])) {
         throw new CommandException('パラメータが足りません。', $this);
     }
     $word = array();
     foreach (mb_split('[\\s ]+', Vars::$get['keyword']) as $w) {
         if ($w != '') {
             $word[] = $w;
         }
     }
     if ($word == array()) {
         return $this->showform();
     }
     $search = Search::getinstance();
     $andsearch = Vars::$get['andor'] == 'and';
     switch (Vars::$get['type']) {
         case 'fuzzy':
             $list = $search->fuzzysearch($word, $andsearch);
             break;
         case 'ereg':
             $list = $search->eregsearch($word, $andsearch);
             break;
         default:
             $list = $search->normalsearch($word, $andsearch);
             break;
     }
     $smarty = $this->getSmarty();
     $smarty->assign('word', join(' ', $word));
     $smarty->assign('type', Vars::$get['type']);
     $smarty->assign('list', $list);
     $ret['title'] = '検索結果';
     $ret['body'] = $smarty->fetch('wordsearchresult.tpl.htm');
     return $ret;
 }
开发者ID:kaz6120,项目名称:BitWiki,代码行数:35,代码来源:search.inc.php

示例15: __construct

 /**
  * @param string $string The string to parse
  * @param ClassObject $extend optional, set if this ClassObject should extend another one
  */
 public function __construct($string, ClassObject $extend = null)
 {
     if ($extend !== null) {
         $this->attributes = $extend->getAttributes();
         $this->methods = $extend->getMethods();
     }
     $pattern = '/' . self::PATTERN . '/i';
     preg_match($pattern, $string, $matches);
     $this->name = $matches[self::PATTERN_NAME_GROUP];
     if (count($matches) > 2) {
         $blocks = preg_split('/\\|/', $matches[2]);
         // Attributes block
         if (count($blocks) > 1) {
             foreach (mb_split(';', $blocks[1]) as $attribute) {
                 if (!empty($attribute)) {
                     $this->attributes[] = new Variable($attribute);
                 }
             }
         }
         // Methods block
         if (count($blocks) > 2) {
             foreach (mb_split(';', $blocks[2]) as $method) {
                 try {
                     $this->methods[] = new Method($method);
                 } catch (\InvalidArgumentException $e) {
                 }
             }
         }
     }
 }
开发者ID:re222dv,项目名称:1DV408-Project,代码行数:34,代码来源:ClassObject.php


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