Initial Kohana install
[speedfreak] / Server / system / core / utf8 / str_split.php
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3  * utf8::str_split
4  *
5  * @package    Core
6  * @author     Kohana Team
7  * @copyright  (c) 2007 Kohana Team
8  * @copyright  (c) 2005 Harry Fuecks
9  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
10  */
11 function _str_split($str, $split_length = 1)
12 {
13         $split_length = (int) $split_length;
14
15         if (utf8::is_ascii($str))
16         {
17                 return str_split($str, $split_length);
18         }
19
20         if ($split_length < 1)
21         {
22                 return FALSE;
23         }
24
25         if (utf8::strlen($str) <= $split_length)
26         {
27                 return array($str);
28         }
29
30         preg_match_all('/.{'.$split_length.'}|[^\x00]{1,'.$split_length.'}$/us', $str, $matches);
31
32         return $matches[0];
33 }