rtrim.php 503 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * UTF8::rtrim
  4. *
  5. * @package Kohana
  6. * @author Kohana Team
  7. * @copyright (c) Kohana Team
  8. * @copyright (c) 2005 Harry Fuecks
  9. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  10. */
  11. function _rtrim($str, $charlist = NULL)
  12. {
  13. if ($charlist === NULL)
  14. return rtrim($str);
  15. if (UTF8::is_ascii($charlist))
  16. return rtrim($str, $charlist);
  17. $charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
  18. return preg_replace('/['.$charlist.']++$/uD', '', $str);
  19. }