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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -