note 105022 deleted from ref.mbstring by danbrown

From: Date: Mon, 25 Jul 2011 12:29:53 +0000
Subject: note 105022 deleted from ref.mbstring by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181838@lists.php.net to get a copy of this message
Note Submitter: luislobo at gmail dot com ---- The mb_str_split below has some errors, here I fixed them and also added a shortcut when the length is less than the split length: function mb_str_split( $string, $split_length = 1 ) { mb_internal_encoding( 'UTF-8' ); mb_regex_encoding( 'UTF-8' ); $split_length = ($split_length <= 0) ? 1 : $split_length; $mb_strlen = mb_strlen( $string, 'utf-8' ); if( $mb_strlen <= $split_length ) { return array( $string ); } $array = array( ); for( $i = 0; $i < $mb_strlen; $i = $i + $split_length ) { $array[] = mb_substr( $string, $i, $split_length ); } return $array; }

« previous php.notes (#181838) next »