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


PHP Utf8::str_split方法代码示例

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


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

示例1:

 /**
  * @covers Patchwork\Utf8::str_split
  */
 function testStr_split()
 {
     $this->assertSame(array('d', 'é', 'j', 'à'), u::str_split('déjà', 1));
     $this->assertSame(array('dé', 'jà'), u::str_split('déjà', 2));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:8,代码来源:Utf8Test.php

示例2: encodeEmail

 /**
  * Encode all e-mail addresses within a string
  *
  * @param string $strString The string to encode
  *
  * @return string The encoded string
  */
 public static function encodeEmail($strString)
 {
     foreach (static::extractEmail($strString) as $strEmail) {
         $strEncoded = '';
         $arrCharacters = Utf8::str_split($strEmail);
         foreach ($arrCharacters as $strCharacter) {
             $strEncoded .= sprintf(rand(0, 1) ? '&#x%X;' : '&#%s;', Utf8::ord($strCharacter));
         }
         $strString = str_replace($strEmail, $strEncoded, $strString);
     }
     return str_replace('mailto:', 'mailto:', $strString);
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:19,代码来源:StringUtil.php

示例3: api_str_split

/**
 * Converts a string to an array.
 * @param string $string				The input string.
 * @param int $split_length				Maximum character-length of the chunk, one character by default.
 * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
 * @return array						The result array of chunks with the spcified length.
 * Notes:
 * If the optional split_length parameter is specified, the returned array will be broken down into chunks
 * with each being split_length in length, otherwise each chunk will be one character in length.
 * FALSE is returned if split_length is less than 1.
 * If the split_length length exceeds the length of string, the entire string is returned as the first (and only) array element.
 * This function is aimed at replacing the function str_split() for human-language strings.
 * @link http://php.net/str_split
 */
function api_str_split($string, $split_length = 1, $encoding = null)
{
    return Utf8::str_split($string, $split_length);
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:18,代码来源:internationalization.lib.php

示例4: utf8_str_split

/**
 * Convert a string to an array
 *
 * @param string $str
 *
 * @return array
 *
 * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
 *             Use Patchwork\Utf8::str_split() instead.
 */
function utf8_str_split($str)
{
    @trigger_error('Using utf8_str_split() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::str_split() instead.', E_USER_DEPRECATED);
    return Utf8::str_split($str);
}
开发者ID:contao,项目名称:core-bundle,代码行数:15,代码来源:functions.php

示例5: test_split_newline

 public function test_split_newline()
 {
     $str = "Iñtërn\nâtiônàl\nizætiøn\n";
     $array = array('I', 'ñ', 't', 'ë', 'r', 'n', "\n", 'â', 't', 'i', 'ô', 'n', 'à', 'l', "\n", 'i', 'z', 'æ', 't', 'i', 'ø', 'n', "\n");
     $this->assertEquals($array, u::str_split($str));
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:6,代码来源:Utf8StrSplitTest.php

示例6: getQuestion

 /**
  * Generate the captcha question
  *
  * @return string The question string
  */
 protected function getQuestion()
 {
     $int1 = rand(1, 9);
     $int2 = rand(1, 9);
     $question = $GLOBALS['TL_LANG']['SEC']['question' . rand(1, 3)];
     $question = sprintf($question, $int1, $int2);
     /** @var SessionInterface $objSession */
     $objSession = \System::getContainer()->get('session');
     $objSession->set('captcha_' . $this->strId, array('sum' => $int1 + $int2, 'key' => $this->strCaptchaKey, 'time' => time()));
     $strEncoded = '';
     $arrCharacters = Utf8::str_split($question);
     foreach ($arrCharacters as $strCharacter) {
         $strEncoded .= sprintf('&#%s;', Utf8::ord($strCharacter));
     }
     return $strEncoded;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:21,代码来源:FormCaptcha.php

示例7: encodeEmail

 /**
  * Encode all e-mail addresses within a string
  *
  * @param string $strString The string to encode
  *
  * @return string The encoded string
  */
 public static function encodeEmail($strString)
 {
     if (strpos($strString, '@') === false) {
         return $strString;
     }
     $arrEmails = static::extractEmail($strString, \Config::get('allowedTags'));
     foreach ($arrEmails as $strEmail) {
         $strEncoded = '';
         $arrCharacters = Utf8::str_split($strEmail);
         foreach ($arrCharacters as $strCharacter) {
             $strEncoded .= sprintf(rand(0, 1) ? '&#x%X;' : '&#%s;', Utf8::ord($strCharacter));
         }
         $strString = str_replace($strEmail, $strEncoded, $strString);
     }
     return str_replace('mailto:', 'mailto:', $strString);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:23,代码来源:StringUtil.php


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