我有一个字符串变量
$p_list="1,2,3,4";
我想将其转换为数组,例如
$a[0]='1';
$a[1]='2';
$a[2]='3';
$a[3]='4';
如何在php中执行此操作?
答案 0 :(得分:3)
答案 1 :(得分:1)
尝试爆炸$a=explode(",","1,2,3,4");
答案 2 :(得分:0)
试试这个:
In PHP, explode function will convert string to array, If string has certain pattern.
<?php
$p_list = "1,2,3,4";
$noArr = explode(",", $p_list);
var_dump($noArr);
?>
You will get array with values stores in it.