将字符串转换为字符数组
在PHP中,我如何转换:
$result = "abdcef";
放入一个数组中,该数组是:
$result[0] = a;
$result[1] = b;
$result[2] = c;
$result[3] = d;
编辑
在PHP中,我如何转换:
$result = "abdcef";
放入一个数组中,该数组是:
$result[0] = a;
$result[1] = b;
$result[2] = c;
$result[3] = d;
编辑
您将需要使用 str_split()。
$result = str_split('abcdef');
不知道你是否已经意识到了这一点,但你可能不需要做任何事情(取决于你想做什么)。
$string = "abcdef";
echo $string[1];
//Outputs "b"
因此,如果您只需要简单的东西,则可以像数组一样访问它,而不会有任何麻烦。