本文整理汇总了PHP中utf8_rtrim函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_rtrim函数的具体用法?PHP utf8_rtrim怎么用?PHP utf8_rtrim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_rtrim函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: utf8_trim
/**
* UTF-8 aware replacement for trim()
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will
* work normally on a UTF-8 string
* @author Andreas Gohr <[email protected]>
* @see http://www.php.net/trim
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @return string
* @package utf8
* @subpackage strings
*/
function utf8_trim($str, $charlist = FALSE)
{
if ($charlist === FALSE) {
return trim($str);
}
return utf8_ltrim(utf8_rtrim($str, $charlist), $charlist);
}
开发者ID:RangerWalt,项目名称:ecci,代码行数:19,代码来源:trim.php
示例2: to_string
function to_string()
{
$uri = $this->get_uri();
$uri->remove_query_items();
$result = array();
$query = '';
$exported = $this->export_attributes();
//removing files data
if (isset($exported['file'])) {
unset($exported['file']);
}
complex_array::to_flat_array($exported, $result);
foreach ($result as $key => $value) {
$query .= $key . '=' . $value . '&';
}
$query = utf8_rtrim($query, '&');
return utf8_rtrim($uri->to_string() . '?' . $query, '?');
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:18,代码来源:request.class.php
示例3: message
if (strlen($title) < 1) {
message($lang_common['Bad request']);
}
$close = isset($_POST['close']) ? intval($_POST['close']) : '2';
$stick = isset($_POST['stick']) ? intval($_POST['stick']) : '2';
$archive = isset($_POST['archive']) ? intval($_POST['archive']) : '2';
$move = isset($_POST['forum']) ? intval($_POST['forum']) : '0';
$leave_redirect = isset($_POST['redirect']) ? intval($_POST['redirect']) : '0';
$insert = array('title' => $title, 'close' => $close, 'stick' => $stick, 'archive' => $archive, 'move' => $move, 'leave_redirect' => $leave_redirect, 'reply_message' => $message, 'add_start' => $add_start, 'add_end' => $add_end, 'send_email' => $send_email, 'increment_posts' => $increment);
$db->insert('multi_moderation', $insert);
redirect(panther_link($panther_url['admin_moderate']), $lang_admin_moderate['added redirect']);
} elseif ($action == 'edit' && $id > '0') {
$message = isset($_POST['message']) ? panther_trim($_POST['message']) : null;
$title = isset($_POST['title']) ? panther_trim($_POST['title']) : null;
$add_start = isset($_POST['add_start']) ? utf8_ltrim($_POST['add_start']) : null;
$add_end = isset($_POST['add_end']) ? utf8_rtrim($_POST['add_end']) : null;
if (strlen($title) > 50) {
message($lang_admin_moderate['title too long']);
}
if (strlen($add_start) > 50 || strlen($add_end) > 50) {
message($lang_admin_moderate['addition too long']);
}
if (strlen($title) < 1) {
message($lang_common['Bad request']);
}
$close = isset($_POST['close']) ? intval($_POST['close']) : '2';
$stick = isset($_POST['stick']) ? intval($_POST['stick']) : '2';
$archive = isset($_POST['archive']) ? intval($_POST['archive']) : '2';
$move = isset($_POST['forum']) ? intval($_POST['forum']) : '0';
$leave_redirect = isset($_POST['redirect']) ? intval($_POST['redirect']) : '0';
$reply = isset($_POST['reply']) ? intval($_POST['reply']) : '0';
开发者ID:mtechnik,项目名称:pantherforum,代码行数:31,代码来源:moderate.php
示例4: rtrim
/**
* UTF-8 aware replacement for rtrim()
* Strip whitespace (or other characters) from the end of a string
* You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
* work normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/rtrim
* @since 11.1
*/
public static function rtrim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false) {
return $str;
}
jimport('phputf8.trim');
if ($charlist === false) {
return utf8_rtrim($str);
} else {
return utf8_rtrim($str, $charlist);
}
}
开发者ID:nogsus,项目名称:joomla-platform,代码行数:27,代码来源:string.php
示例5: trim
/**
* UTF-8 aware replacement for trim()
*
* Strip whitespace (or other characters) from the beginning and end of a string
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise trim will
* work normally on a UTF-8 string
*
* @param string the string to be trimmed
* @param string the optional charlist of additional characters to trim
* @return string the trimmed string
* @see http://www.php.net/trim
*/
public static function trim($str, $charlist = FALSE)
{
if ($charlist === FALSE) {
return trim($str);
}
return KHelperString::ltrim(utf8_rtrim($str, $charlist), $charlist);
}
开发者ID:stonyyi,项目名称:anahita,代码行数:20,代码来源:string.php
示例6: rtrim
/**
* UTF-8 aware replacement for rtrim()
* Strip whitespace (or other characters) from the end of a string
* Note: you only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
* work normally on a UTF-8 string
*
* @static
* @access public
* @param string the string to be trimmed
* @param string the optional charlist of additional characters to trim
* @return string the trimmed string
* @see http://www.php.net/rtrim
*/
public static function rtrim($str, $charlist = FALSE)
{
jimport('phputf8.trim');
if ($charlist === FALSE) {
return utf8_rtrim($str);
} else {
return utf8_rtrim($str, $charlist);
}
}
开发者ID:joebushi,项目名称:joomla,代码行数:23,代码来源:string.php
示例7: rtrim
/**
* UTF-8 aware replacement for rtrim()
* Strip whitespace (or other characters) from the end of a string
* You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
* work normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/rtrim
* @since 2.0
*/
public static function rtrim($str, $charlist = null)
{
if (empty($charlist) && $charlist !== null) {
return $str;
}
if (!function_exists('utf8_rtrim')) {
require_once __DIR__ . '/phputf8/trim.php';
}
if ($charlist === null) {
return utf8_rtrim($str);
}
return utf8_rtrim($str, $charlist);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:28,代码来源:Utf8String.php
示例8: rtrim
/**
* UTF-8 aware replacement for rtrim()
* Strip whitespace (or other characters) from the end of a string
* You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will
* work normally on a UTF-8 string
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/rtrim
* @since 1.0
*/
public static function rtrim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false) {
return $str;
}
require_once __DIR__ . '/phputf8/trim.php';
if ($charlist === false) {
return utf8_rtrim($str);
}
return utf8_rtrim($str, $charlist);
}
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:26,代码来源:String.php
示例9: utf8_trim
/**
* utf8_trim( )
*
* Strip whitespace or other characters from beginning or end of a UTF-8 string
* @since 1.3
*
* @param string $string The string to be trimmed
* @param string $chrs Optional characters to be stripped
* @return string The trimmed string
*/
function utf8_trim($string = '', $chrs = '')
{
$string = utf8_ltrim($string, $chrs);
return utf8_rtrim($string, $chrs);
}
开发者ID:henrique-lima,项目名称:rabbit-internet,代码行数:15,代码来源:Utf8Parser.php
示例10: utf8_trim
/**
* Unicode aware replacement for trim()
*
* @author Andreas Gohr <[email protected]>
* @see trim()
* @return string
*/
function utf8_trim($str, $charlist = '')
{
if ($charlist == '') {
return trim($str);
}
return utf8_ltrim(utf8_rtrim($str));
}
开发者ID:BackupTheBerlios,项目名称:stato-svn,代码行数:14,代码来源:utf8_helper.php
示例11: rtrim
/**
* UTF-8 aware replacement for rtrim()
*
* Strip whitespace (or other characters) from the end of a string. You only need to use this if you are supplying the charlist
* optional arg and it contains UTF-8 characters. Otherwise rtrim will work normally on a UTF-8 string.
*
* @param string $str The string to be trimmed
* @param string $charlist The optional charlist of additional characters to trim
*
* @return string The trimmed string
*
* @see http://www.php.net/rtrim
* @since 1.3.0
*/
public static function rtrim($str, $charlist = false)
{
if (empty($charlist) && $charlist !== false) {
return $str;
}
if ($charlist === false) {
return utf8_rtrim($str);
}
return utf8_rtrim($str, $charlist);
}
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:24,代码来源:StringHelper.php
示例12: testLinefeedMask
function testLinefeedMask()
{
$str = "Iñtërnâtiônàlizætiø\nø";
$trimmed = "Iñtërnâtiônàlizæti";
$this->assertEqual(utf8_rtrim($str, "ø\n"), $trimmed);
}
开发者ID:kidwellj,项目名称:scuttle,代码行数:6,代码来源:utf8_trim.test.php
示例13: utf8_trim
/**
* UTF-8 aware replacement for trim().
*
* @author Andreas Gohr <[email protected]>
* @see http://www.php.net/trim
* @see http://dev.splitbrain.org/view/darcs/dokuwiki/inc/utf8.php
* @param string $str
* @param boolean $charlist
* @return string
*/
function utf8_trim($str, $charlist = '')
{
if (empty($charlist)) {
return trim($str);
}
return utf8_ltrim(utf8_rtrim($str, $charlist), $charlist);
}
开发者ID:kidaa30,项目名称:Swevers,代码行数:17,代码来源:text.php
示例14: strmaxlen
/**
* Crop string to maxlen with … (default tail) at the end if needed.
*
* If $format is not "raw", we make sure to not cut in the middle of an
* HTML entity, so that strmaxlen('1&2', 3, NULL, 'formvalue') will not
* become/stay '1&…'.
*
* @param string
* @param int Maximum length
* @param string Tail to use, when string gets cropped. Its length gets
* substracted from the total length (with HTML entities
* being decoded). Default is "…" (HTML entity)
* @param string Format, see {@link format_to_output()}
* @param boolean Crop at whitespace, if possible?
* (any word split at the end will get its head removed)
* @return string
*/
function strmaxlen($str, $maxlen = 50, $tail = NULL, $format = 'raw', $cut_at_whitespace = false)
{
if (is_null($tail)) {
$tail = '…';
}
$str = utf8_rtrim($str);
if (utf8_strlen($str) > $maxlen) {
// Replace all HTML entities by a single char. html_entity_decode for example
// would not handle ….
$tail_for_length = preg_replace('~&\\w+?;~', '.', $tail);
$tail_length = utf8_strlen(html_entity_decode($tail_for_length));
$len = $maxlen - $tail_length;
if ($len < 1) {
// special case; $tail length is >= $maxlen
$len = 0;
}
$str_cropped = utf8_substr($str, 0, $len);
if ($format != 'raw') {
// if the format isn't raw we make sure that we do not cut in the middle of an HTML entity
$maxlen_entity = 7;
# "&" is 5, min 3!
$str_inspect = utf8_substr($str_cropped, 1 - $maxlen_entity);
$pos_amp = utf8_strpos($str_inspect, '&');
if ($pos_amp !== false) {
// there's an ampersand at the end of the cropped string
$look_until = $pos_amp;
$str_cropped_len = utf8_strlen($str_cropped);
if ($str_cropped_len < $maxlen_entity) {
// we have to look at least for the length of an entity
$look_until += $maxlen_entity - $str_cropped_len;
}
if (strpos(utf8_substr($str, $len, $look_until), ';') !== false) {
$str_cropped = utf8_substr($str, 0, $len - utf8_strlen($str_inspect) + $pos_amp);
}
}
}
if ($cut_at_whitespace) {
// Get the first character being cut off. Note: we can't use $str[index] in case of utf8 strings!
$first_cut_off_char = utf8_substr($str, utf8_strlen($str_cropped), 1);
if (!ctype_space($first_cut_off_char)) {
// first character being cut off is not whitespace
// Get the chars as an array from the cropped string to be able to get chars by position
$str_cropped_chars = preg_split('//u', $str_cropped, -1, PREG_SPLIT_NO_EMPTY);
$i = utf8_strlen($str_cropped);
while ($i && isset($str_cropped_chars[--$i]) && !ctype_space($str_cropped_chars[$i])) {
}
if ($i) {
$str_cropped = utf8_substr($str_cropped, 0, $i);
}
}
}
$str = format_to_output(utf8_rtrim($str_cropped), $format);
$str .= $tail;
return $str;
} else {
return format_to_output($str, $format);
}
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:75,代码来源:_misc.funcs.php
示例15: utf8_rtrim
function utf8_rtrim($str, $charlist = '')
{
return utf8_rtrim($str, $charlist);
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:4,代码来源:utf8_integration_test.class.php
注:本文中的utf8_rtrim函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论