Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 一个字符串,其内容为数组到一个新数组_Php_Arrays_String_Function - Fatal编程技术网

Php 一个字符串,其内容为数组到一个新数组

Php 一个字符串,其内容为数组到一个新数组,php,arrays,string,function,Php,Arrays,String,Function,我有一个html格式的表单,它将采用一个巨大的字符串,后面用空格、逗号和空格分隔,每个项目都用引号括起来,如下所示: $s = '"info1" , "info2"'; //and so on 所以我的问题是如何创建一个新的数组变量并将字符串中的信息设置为数组中的信息?基本上是这样做的: $array_ex = array("info1", "info2"); //of course there is going to be

我有一个html格式的表单,它将采用一个巨大的字符串,后面用空格、逗号和空格分隔,每个项目都用引号括起来,如下所示:

$s = '"info1" , "info2"'; //and so on
所以我的问题是如何创建一个新的数组变量并将字符串中的信息设置为数组中的信息?基本上是这样做的:

$array_ex = array("info1", "info2"); //of course there is going to be
                                     //way more than 2 items
可能吗


谢谢

explode函数用于从具有特定分隔字符的字符串生成数组

$s = '"info1" , "info2"' //and so on

$array = explode(",",$s);


print_r($array)
作为上述问题的解决方案,您需要使用explode函数从用逗号分隔的字符串生成数组

e、 g

        $a=explode(",",$string);
有关explode函数的更多详细信息,请参阅以下url中提到的文档


关于堆栈溢出,每天至少有一个这样的问题。请参阅explode和其他许多问题。好的,我会的,很抱歉,我不知道要搜索什么。谢谢你可以看看这个: