Support Joomla!

Packages

Package: utf8

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /phputf8/str_split.php

Documentation is available at str_split.php

  1. <?php
  2. /**
  3. @version $Id: str_split.php 10381 2008-06-01 03:35:53Z pasamio $
  4. @package utf8
  5. @subpackage strings
  6. */
  7.  
  8. //---------------------------------------------------------------
  9. /**
  10. * UTF-8 aware alternative to str_split
  11. * Convert a string to an array
  12. * Note: requires utf8_strlen to be loaded
  13. @param string UTF-8 encoded
  14. @param int number to characters to split string by
  15. @return string characters in string reverses
  16. @see http://www.php.net/str_split
  17. @see utf8_strlen
  18. @package utf8
  19. @subpackage strings
  20. */
  21. function utf8_str_split($str$split_len 1{
  22.  
  23.     if !preg_match('/^[0-9]+$/',$split_len|| $split_len {
  24.         return FALSE;
  25.     }
  26.  
  27.     $len utf8_strlen($str);
  28.     if $len <= $split_len {
  29.         return array($str);
  30.     }
  31.  
  32.     preg_match_all('/.{'.$split_len.'}|[^\x00]{1,'.$split_len.'}$/us'$str$ar);
  33.     return $ar[0];
  34.  
  35. }

Documentation generated on Sun, 21 Dec 2008 20:50:26 +0000 by phpDocumentor 1.3.1