CoreFiles by mySites.guru
str_split.php35 lines, 870 bytes, from Joomla_1.5.0-Stable-Full_Package.zip
Raw History Compare with 1.0.15
md5
779be3d273eb67751daba3abb7c8d903
sha1
a8ed71e31894d9480eb5e375ed217ecf9b24d1b3
sha256
99427d20492e682e45b396f1efb5d8568605a0b4d8f1844f717ae294976f6b4f
<?php
/**
* @version $Id: str_split.php 7692 2007-06-08 20:41:29Z tcp $
* @package utf8
* @subpackage strings
*/

//---------------------------------------------------------------
/**
* UTF-8 aware alternative to str_split
* Convert a string to an array
* Note: requires utf8_strlen to be loaded
* @param string UTF-8 encoded
* @param int number to characters to split string by
* @return string characters in string reverses
* @see http://www.php.net/str_split
* @see utf8_strlen
* @package utf8
* @subpackage strings
*/
function utf8_str_split($str, $split_len = 1) {

    if ( !preg_match('/^[0-9]+$/',$split_len) || $split_len < 1 ) {
        return FALSE;
    }

    $len = utf8_strlen($str);
    if ( $len <= $split_len ) {
        return array($str);
    }

    preg_match_all('/.{'.$split_len.'}|[^\x00]{1,'.$split_len.'}$/us', $str, $ar);
    return $ar[0];

}

The same content is in 4 releases, Joomla 1.5.0 to 1.5.3. See them all, or every version of this file.