php - How to get first 5 characters from string -
how first 5 characters string using php
$mystr = "hellowordl";
result should this
$result = "hello";
for single-byte strings (e.g. us-ascii, iso 8859 family, etc.) use substr
, multi-byte strings (e.g. utf-8, utf-16, etc.) use mb_substr
:
// singlebyte strings $result = substr($mystr, 0, 5); // multibyte strings $result = mb_substr($mystr, 0, 5);
Comments
Post a Comment