要将PHP字符串转换为数组,可以使用PHP中的explode()函数。该函数可以通过指定一个分隔符来将字符串拆分为数组。例如:
$str = "apple,banana,orange";
$arr = explode(",", $str);
print_r($arr);
// 输出结果
// Array
// (
// [0] => apple
// [1] => banana
// [2] => orange
// )
在上面的例子中,我们将逗号作为分隔符,将字符串"apple,banana,orange"拆分为一个包含3个元素的数组。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:php怎么将字符串转换为数组