从逗号分隔的列表生成阵列 - PHP [英] Generate Array from a comma-separated list - PHP
本文介绍了从逗号分隔的列表生成阵列 - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有像这样定义一个变量: $ VAR =1,2,3; &安培;我有一个数组: $ thePostIdArray =阵列(1,2,3);
I have a variable defined like so: $var = "1, 2, 3"; & I have an array: $thePostIdArray = array(1, 2, 3);
上面的阵列致力于通过其循环时巨大的,但是当我尝试使用的 $ VAR 到位逗号分隔的列表中,会出现问题。
The Array above works great when looping through it but when I try to use the $var in place of the comma-separated list, problems occur.
所以,(完美世界),它可能是的 $ thePostIdArray =阵列($ VAR); 这将是一样的 $ thePostIdArray =阵列(1,2,3); 。
So (perfect world) it could be $thePostIdArray = array($var); which would be the same as $thePostIdArray = array(1, 2, 3);.
的将尽力到目前为止还没有工作:(的
这甚至可能,或有更简单的解决方法吗?
感谢您的任何指针。
推荐答案
查看 爆炸
: $ thePostIdArray =爆炸('',$ VAR);
这篇关于从逗号分隔的列表生成阵列 - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文