note 112624 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 19:40:07 +0000 |
| Subject: | note 112624 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218735@lists.php.net to get a copy of this message | ||
Note Submitter: jakub dot lopuszanski at nasza-klasa dot pl
----
To split UTF-8 into 16-charcater slices you can use:
<?php
preg_split('/(?=(.{16})*$)/u', $text);
?>
You can also use look-behind instead of look-ahead if you want the first (not the last) chunk to be
the shortest.