/system/utf8/rtrim.php
PHP | 38 lines | 12 code | 3 blank | 23 comment | 2 complexity | 8847315ef598365d82121c1d6cbc73f9 MD5 | raw file
- <?php
- /**
- * This file is part of the Yet Another PHP Framework package.
- * (c) 2010 Adrian Videnie <{@link mailto:avidenie@gmail.com avidenie@gmail.com}>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @package Framework
- * @subpackage I18n
- * @author Adrian Videnie <avidenie@gmail.com>
- * @copyright 2010 Adrian Videnie
- * @license http://www.opensource.org/licenses/mit-license.php The MIT license
- */
- /**
- * Multi-byte aware version of rtrim native PHP function.
- *
- * @see http://php.net/rtrim
- * @author Andreas Gohr <andi@splitbrain.org>
- *
- * @param string The input string.
- * @param string The list of characters you want to strip.
- * @return string
- */
- function _rtrim($str, $charlist = null)
- {
- if (null === $charlist) {
- return rtrim($str);
- }
- if (Utf8::isAscii($charlist)) {
- return rtrim($str, $charlist);
- }
- $charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
- return preg_replace('/['.$charlist.']++$/uD', '', $str);
- }