PageRenderTime 1212ms CodeModel.GetById 44ms RepoModel.GetById 2ms app.codeStats 0ms

/system/utf8/rtrim.php

https://github.com/avidenie/Yet-Another-PHP-Framework
PHP | 38 lines | 12 code | 3 blank | 23 comment | 2 complexity | 8847315ef598365d82121c1d6cbc73f9 MD5 | raw file
  1. <?php
  2. /**
  3. * This file is part of the Yet Another PHP Framework package.
  4. * (c) 2010 Adrian Videnie <{@link mailto:avidenie@gmail.com avidenie@gmail.com}>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. *
  9. * @package Framework
  10. * @subpackage I18n
  11. * @author Adrian Videnie <avidenie@gmail.com>
  12. * @copyright 2010 Adrian Videnie
  13. * @license http://www.opensource.org/licenses/mit-license.php The MIT license
  14. */
  15. /**
  16. * Multi-byte aware version of rtrim native PHP function.
  17. *
  18. * @see http://php.net/rtrim
  19. * @author Andreas Gohr <andi@splitbrain.org>
  20. *
  21. * @param string The input string.
  22. * @param string The list of characters you want to strip.
  23. * @return string
  24. */
  25. function _rtrim($str, $charlist = null)
  26. {
  27. if (null === $charlist) {
  28. return rtrim($str);
  29. }
  30. if (Utf8::isAscii($charlist)) {
  31. return rtrim($str, $charlist);
  32. }
  33. $charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
  34. return preg_replace('/['.$charlist.']++$/uD', '', $str);
  35. }