note 113274 added to function.str-split

From: Date: Thu, 19 Sep 2013 20:31:49 +0000
Subject: note 113274 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-196317@lists.php.net to get a copy of this message
A new version of "str_split_unicode" prev. <?php function str_split_unicode($str, $length = 1) { $tmp = preg_split('~~u', $str, -1, PREG_SPLIT_NO_EMPTY); if ($length > 1) { $chunks = array_chunk($tmp, $length); foreach ($chunks as $i => $chunk) { $chunks[$i] = join('', (array) $chunk); } $tmp = $chunks; } return $tmp; } ?> $s = 'Özgür Yazılım!'; // Open Source! print_r(str_split_unicode($s)); print_r(str_split_unicode($s, 3)); Array ( [0] => Ö [1] => z [2] => g [3] => ü [4] => r [5] => [6] => Y [7] => a [8] => z [9] => ı [10] => l [11] => ı [12] => m [13] => ! ) Array ( [0] => Özg [1] => ür [2] => Yaz [3] => ılı [4] => m! ) ---- Server IP: 69.147.83.199 Probable Submitter: 5.47.130.116 ---- Manual Page -- http://php.net/manual/en/function.str-split.php Edit -- https://master.php.net/note/edit/113274 Del: integrated -- https://master.php.net/note/delete/113274/integrated Del: useless -- https://master.php.net/note/delete/113274/useless Del: bad code -- https://master.php.net/note/delete/113274/bad+code Del: spam -- https://master.php.net/note/delete/113274/spam Del: non-english -- https://master.php.net/note/delete/113274/non-english Del: in docs -- https://master.php.net/note/delete/113274/in+docs Del: other reasons-- https://master.php.net/note/delete/113274 Reject -- https://master.php.net/note/reject/113274 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196317) next »