首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

帮忙解决下数组的有关问题!(初学者问.)

2012-03-16 
帮忙解决下数组的问题!(菜鸟问..)就是说现在一个变量$p的数据是221,567,568,569,572,573,1408,1723,1724,1

帮忙解决下数组的问题!(菜鸟问..)
就是说现在一个变量$p的数据是221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587  
这是echo出来的...
现在要怎么定义一个数组..把这些数据一个一个放到数据里面去...
$s[0]=221,$s[1]=567............


请各位大哥帮帮忙啊!

[解决办法]
$p= "221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587 "
$s = explode( ', ', $p);
print_r($s);


[解决办法]
$p = '221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587 ';
$s = explode( ', ',$p);
print_r($s);

-------------------

---------- PHP调试 ----------
Array
(
[0] => 221
[1] => 567
[2] => 568
[3] => 569
[4] => 572
[5] => 573
[6] => 1408
[7] => 1723
[8] => 1724
[9] => 1725
[10] => 1726
[11] => 1727
[12] => 1728
[13] => 1729
[14] => 1730
[15] => 1731
[16] => 1732
[17] => 1733
[18] => 2586
[19] => 13587
)

输出完成 (耗时: 0 秒) - 正常终止
[解决办法]
$p= "221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587 "

print_r(split( ", ",$p));

这样也行..
[解决办法]
$p= "221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587 ";
$s=explode( ", ",$p);
-------------
echo $s;//输出array
-------------
这样就把$p中的数据存入数组$s中了:$s[0]=221;$s[1]=567.........$[19]=13587;

[解决办法]
$p= "221,567,568,569,572,573,1408,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,2586,13587 "
$s = explode( ', ', $p);
print_r($s);
[解决办法]
...楼上的

explode还有这鸟函数 我还在用split呢
我日 php就是恶心 同一功能N个函数 不累死人

顺便问下大家 2000-01-09 20:30:20
怎么输出2000-01-09
难道用explode分割 " "吗?
有象asp中的datevalue 类似的函数吗?

热点排行