How to get first 5 characters from string using php
The following PHP snippet will get the first 5, 10, 20, or 50 characters from a variable.
example:
$myStr = "HelloWordl";
Result like this
$result = "Hello";
Here's the ticket!
singlebyte strings
substr($myStr, 0, 5);
multibyte strings
mb_substr($myStr, 0, 5);