note 100467 deleted from function.substr by peehaa
| From: | peehaa@php.net | Date: | Mon, 28 Nov 2016 19:50:56 +0000 |
| Subject: | note 100467 deleted from function.substr by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207720@lists.php.net to get a copy of this message | ||
Note Submitter: magickey
----
Simple UTF-8 Multibyte solution (without mb_substr)
<?php
$string="texto en español";
echo substr($string,0,14); //Outputs: texto en espa�
?>
<?php
$string="texto en español";
echo utf8_encode(substr(utf8_decode($string),0,14)); //Outputs: texto en españ
?>