本文整理汇总了PHP中utf8_str_split函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_str_split函数的具体用法?PHP utf8_str_split怎么用?PHP utf8_str_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_str_split函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: decorateYear
/**
* Decorates the given year.
*
* @param $year
* @return string
*/
protected function decorateYear($year)
{
$year = utf8_str_split($year);
$modifier = '״' . array_pop($year);
array_push($year, $modifier);
return implode($year);
}
开发者ID:kfirba,项目名称:hebdate,代码行数:13,代码来源:PresentableHebrewDate.php
示例2: sum
/**
* Get the sum of the word numerical representation.
*
* @param $word
* @param bool $hebrewYear
* @return number
*/
public function sum($word, $hebrewYear = false)
{
$this->validateHebrewCharactersOnly($word);
$letters = utf8_str_split($word);
$letters[0] = $letters[0] == 'ה' && $hebrewYear ? 5000 : $letters[0];
return array_sum(array_map(function ($letter) {
return is_numeric($letter) ? $letter : self::numerology[$letter];
}, $letters));
}
开发者ID:kfirba,项目名称:hebdate,代码行数:16,代码来源:HebrewNumerology.php
示例3: CheckUpperLetters
function CheckUpperLetters($st)
{
$lv = "AĀBCČDEĒFGĢHIĪJKĶLĻMNŅOPRSŠTUŪVZŽ";
$arr1 = utf8_str_split($st);
$let = $arr1[0];
// 1 burts
$arr2 = utf8_str_split($lv);
// char of latvian upper letters
for ($i = 0; $i < strlen($lv) - 1; $i++) {
if ($let == $arr2[$i]) {
return TRUE;
}
}
return FALSE;
}
开发者ID:arturslukins,项目名称:rvt,代码行数:15,代码来源:validate.php
示例4: str_split
/**
* UTF-8 aware alternative to str_split
* Convert a string to an array
*
* @param string $str UTF-8 encoded string to process
* @param integer $split_len Number to characters to split string by
*
* @return array
*
* @see http://www.php.net/str_split
* @since 11.1
*/
public static function str_split($str, $split_len = 1)
{
jimport('phputf8.str_split');
return utf8_str_split($str, $split_len);
}
开发者ID:nogsus,项目名称:joomla-platform,代码行数:17,代码来源:string.php
示例5: mail_encode
/**
* Encodes the given string for proper display in UTF-8.
*
* This version is using base64 encoded data. The downside of this
* is if the mail client does not understand this encoding the user
* is basically doomed with an unreadable subject.
*
* Please note that this version fully supports RFC 2045 section 6.8.
*/
function mail_encode($str)
{
// define start delimimter, end delimiter and spacer
$start = "=?UTF-8?B?";
$end = "?=";
$spacer = $end . ' ' . $start;
$split_length = 64;
$encoded_str = base64_encode($str);
// If encoded string meets the limits, we just return with the correct data.
if (strlen($encoded_str) <= $split_length) {
return $start . $encoded_str . $end;
}
// If there is only ASCII data, we just return what we want, correctly splitting the lines.
if (strlen($str) === utf8_strlen($str)) {
return $start . implode($spacer, str_split($encoded_str, $split_length)) . $end;
}
// UTF-8 data, compose encoded lines
$array = utf8_str_split($str);
$str = '';
while (sizeof($array)) {
$text = '';
while (sizeof($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length) {
$text .= array_shift($array);
}
$str .= $start . base64_encode($text) . $end . ' ';
}
return substr($str, 0, -1);
}
开发者ID:jvinhit,项目名称:php,代码行数:37,代码来源:functions_messenger.php
示例6: truncate_string
/**
* Truncates string while retaining special characters if going over the max length
* The default max length is 60 at the moment
* The maximum storage length is there to fit the string within the given length. The string may be further truncated due to html entities.
* For example: string given is 'a "quote"' (length: 9), would be a stored as 'a "quote"' (length: 19)
*
* @param string $string The text to truncate to the given length. String is specialchared.
* @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char)
* @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars).
* @param bool $allow_reply Allow Re: in front of string
* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated.
* @param string $append String to be appended
*/
function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '')
{
$chars = array();
$strip_reply = false;
$stripped = false;
if ($allow_reply && strpos($string, 'Re: ') === 0) {
$strip_reply = true;
$string = substr($string, 4);
}
$_chars = utf8_str_split(htmlspecialchars_decode($string));
$chars = array_map('utf8_htmlspecialchars', $_chars);
// Now check the length ;)
if (sizeof($chars) > $max_length) {
// Cut off the last elements from the array
$string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append)));
$stripped = true;
}
// Due to specialchars, we may not be able to store the string...
if (utf8_strlen($string) > $max_store_length) {
// let's split again, we do not want half-baked strings where entities are split
$_chars = utf8_str_split(htmlspecialchars_decode($string));
$chars = array_map('utf8_htmlspecialchars', $_chars);
do {
array_pop($chars);
$string = implode('', $chars);
} while (!empty($chars) && utf8_strlen($string) > $max_store_length);
}
if ($strip_reply) {
$string = 'Re: ' . $string;
}
if ($append != '' && $stripped) {
$string = $string . $append;
}
return $string;
}
开发者ID:41px,项目名称:phpbb-auth-passage,代码行数:48,代码来源:functions_content.php
示例7: 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);
$this->Session->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:StephenGWills,项目名称:sample-contao-app,代码行数:19,代码来源:FormCaptcha.php
示例8: mail_encode
/**
* Encodes the given string for proper display in UTF-8.
*
* This version is using base64 encoded data. The downside of this
* is if the mail client does not understand this encoding the user
* is basically doomed with an unreadable subject.
*
* Please note that this version fully supports RFC 2045 section 6.8.
*
* @param string $eol End of line we are using (optional to be backwards compatible)
*/
function mail_encode($str, $eol = "\r\n")
{
// define start delimimter, end delimiter and spacer
$start = "=?UTF-8?B?";
$end = "?=";
$delimiter = "{$eol} ";
// Maximum length is 75. $split_length *must* be a multiple of 4, but <= 75 - strlen($start . $delimiter . $end)!!!
$split_length = 60;
$encoded_str = base64_encode($str);
// If encoded string meets the limits, we just return with the correct data.
if (strlen($encoded_str) <= $split_length) {
return $start . $encoded_str . $end;
}
// If there is only ASCII data, we just return what we want, correctly splitting the lines.
if (strlen($str) === utf8_strlen($str)) {
return $start . implode($end . $delimiter . $start, str_split($encoded_str, $split_length)) . $end;
}
// UTF-8 data, compose encoded lines
$array = utf8_str_split($str);
$str = '';
while (sizeof($array)) {
$text = '';
while (sizeof($array) && intval((strlen($text . $array[0]) + 2) / 3) << 2 <= $split_length) {
$text .= array_shift($array);
}
$str .= $start . base64_encode($text) . $end . $delimiter;
}
return substr($str, 0, -strlen($delimiter));
}
开发者ID:mysteriou,项目名称:educafacile.com,代码行数:40,代码来源:functions_messenger.php
示例9: str_split
/**
* UTF-8 aware alternative to str_split
* Convert a string to an array
*
* @param string $str UTF-8 encoded string to process
* @param integer $split_len Number to characters to split string by
*
* @return array
*
* @see http://www.php.net/str_split
* @since 2.0
*/
public static function str_split($str, $split_len = 1)
{
if (!function_exists('utf8_str_split')) {
require_once __DIR__ . '/phputf8/str_split.php';
}
return utf8_str_split($str, $split_len);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:19,代码来源:Utf8String.php
示例10: testSplitNewline
function testSplitNewline()
{
$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->assertEqual(utf8_str_split($str), $array);
}
开发者ID:kidwellj,项目名称:scuttle,代码行数:6,代码来源:utf8_str_split.test.php
示例11: str_split
/**
* UTF-8 aware alternative to str_split
* Convert a string to an array
*
* @param string $str UTF-8 encoded string to process
* @param integer $split_len Number to characters to split string by
*
* @return array
*
* @see http://www.php.net/str_split
* @since 1.0
*/
public static function str_split($str, $split_len = 1)
{
require_once __DIR__ . '/phputf8/str_split.php';
return utf8_str_split($str, $split_len);
}
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:17,代码来源:String.php
示例12: str_split
/**
* UTF-8 aware alternative to str_split()
*
* Convert a string to an array.
*
* @param string $str UTF-8 encoded string to process
* @param integer $split_len Number to characters to split string by
*
* @return array
*
* @see http://www.php.net/str_split
* @since 1.3.0
*/
public static function str_split($str, $split_len = 1)
{
return utf8_str_split($str, $split_len);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:17,代码来源:StringHelper.php
示例13: 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)
{
$arrEmails = array();
preg_match_all('/\\w([-.+!#$%&\'*\\/=?^`{}|~\\w]*\\w)?@\\w([-.\\w]*\\w)?\\.\\w{2,63}/u', $strString, $arrEmails);
foreach ((array) $arrEmails[0] 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:eknoes,项目名称:core,代码行数:21,代码来源:StringUtil.php
注:本文中的utf8_str_split函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论