This gets the first 5 characters of a string
‘Monday’ Becomes ‘Monda’
and ‘saturday’ Becomes ‘satur’
For single-byte strings (e.g. US-ASCII, ISO 8859 family, etc.) use substr and for multi-byte strings (e.g. UTF-8, UTF-16, etc.) use mb_substr:
1 2 3 4 5 6 |
// singlebyte strings $result = substr($myStr, 0, 5); // multibyte strings $result = mb_substr($myStr, 0, 5); |
Below starts from the third character
1 2 3 4 |
$divid = "dog12345"; echo $divid = substr($divid, 3); |
The above result would be 12345