ltrim.php 501 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * UTF8::ltrim
  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 _ltrim($str, $charlist = NULL)
  12. {
  13. if ($charlist === NULL)
  14. return ltrim($str);
  15. if (UTF8::is_ascii($charlist))
  16. return ltrim($str, $charlist);
  17. $charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
  18. return preg_replace('/^['.$charlist.']+/u', '', $str);
  19. }