Bump version to 3.3.6
[kohana-core.git] / utf8 / str_split.php
blobdfc6d92e976449f674f4fded988f948c7dcebff6
1 <?php defined('SYSPATH') OR die('No direct script access.');
2 /**
3 * UTF8::str_split
5 * @package Kohana
6 * @author Kohana Team
7 * @copyright (c) 2007-2012 Kohana Team
8 * @copyright (c) 2005 Harry Fuecks
9 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
11 function _str_split($str, $split_length = 1)
13 $split_length = (int) $split_length;
15 if (UTF8::is_ascii($str))
16 return str_split($str, $split_length);
18 if ($split_length < 1)
19 return FALSE;
21 if (UTF8::strlen($str) <= $split_length)
22 return array($str);
24 preg_match_all('/.{'.$split_length.'}|[^\x00]{1,'.$split_length.'}$/us', $str, $matches);
26 return $matches[0];