更新时间:2023-02-18 20:56:03
$阵列= str_split(0123456789bcdfghjkmnpqrstvwxyz);
str_split还需要第二个参数,该块长度,所以你可以做这样的事情:
$阵列= str_split(AABBCCDD,2);// $数组[0] = AA
// $阵列[1] = BB
// $阵列[2] = CC等..
您还可以通过将其作为一个数组得到你的字符串的部分:
$字符串=你好;
回声$字符串[1];//输出E
I have a string such as:
"0123456789"
and need to split EACH character into an array.
I for the hell of it tried:
explode('', '123545789');
But it gave me the obvious: Warning: No delimiter defined in explode) ..
How would I come across this? I can't see any method off hand, especially just a function
$array = str_split("0123456789bcdfghjkmnpqrstvwxyz");
str_split also takes a 2nd param, the chunk length, so you can do things like:
$array = str_split("aabbccdd",2);
// $array[0] = aa
// $array[1] = bb
// $array[2] = cc etc ...
You can also get at parts of your string by treating it as an array:
$string = "hello";
echo $string[1];
// outputs "e"