source: branches/rsr.v5.1.1/web/punbb/include/utf8/str_split.php

Last change on this file was 3, checked in by dj3c1t, 13 years ago

passage a Fluxbb 1.4.7

File size: 762 bytes
Line 
1<?php
2
3/**
4* @version $Id: str_split.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
5* @package utf8
6* @subpackage strings
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*/
21function utf8_str_split($str, $split_len=1)
22{
23        if (!preg_match('/^[0-9]+$/',$split_len) || $split_len < 1)
24                return false;
25
26        $len = utf8_strlen($str);
27        if ($len <= $split_len)
28                return array($str);
29
30        preg_match_all('/.{'.$split_len.'}|[^\x00]{1,'.$split_len.'}$/us', $str, $ar);
31
32        return $ar[0];
33}
Note: See TracBrowser for help on using the repository browser.