The string operation has a variable: $ arr [0] 1. I want to determine the length of the variable, which contains several characters. how can I do this? 2. what should I do if I want to take two places on the left? Just getting started with PHP, please teach me ------ solution ------------------ $ nstrlen ($ arr [0]); $ msubstr ($ arr [0],); ------ solution ---------- string operation
There is a variable: $ arr [0]
1. how can I determine the length of a string containing several characters?
2. what should I do if I want to take two places on the left?
I just got in touch with PHP. please teach me
------ Solution --------------------
$ N = strlen ($ arr [0]);
$ M = substr ($ arr [0], 0, 2 );
------ Solution --------------------
Int strlen (string)
Get the string length, strlen (your string)
String substr (string, int start [, int length])
Substr (your string, 0, 2 );
------ Solution --------------------
$ Len = strlen ($ arr [0]);
$ Str = substr ($ arr [0], 0, 2 );
------ Solution --------------------
Pay attention to whether the string contains wide characters.
------ Solution --------------------
The width is unicode.