2012-12-28 37 views
-4

我有一个HTML格式,将采用一个巨大的字符串分隔空白,逗号和后面的空白,每个项目都用引号括起来,如下所示:一个字符串的数组内容到一个新的数组php

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

所以我的问题是我将如何做一个新的数组变量,并将字符串中的信息设置为数组中的信息?基本上是这样的:

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

这可能吗?

谢谢!

+3

Stack O至少有一个这样的问题verflow。看到'爆炸'和许多其他问题。 –

+0

好的,我会的,对不起,我不知道要搜索什么。谢谢 – Baruch

+0

你可以看看这个:http://php.net/manual/en/function.explode.php http://php.net/manual/en/function.preg-split.php – Josay

回答

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

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


print_r($array) 
0

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

至于你上面提到的问题的解决方案,你需要使用爆炸功能从使用逗号

 $a=explode(",",$string); 

分隔的有关爆炸的功能,请参阅文件的详细信息的字符串数组在以下网址中提到

http://php.net/manual/en/function.explode.php

相关问题