帮忙解决下数组的有关问题!(初学者问.)
程序员文章站
2022-06-16 12:07:50
...
帮忙解决下数组的问题!(菜鸟问..)
就是说现在一个变量$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 类似的函数吗?
就是说现在一个变量$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 类似的函数吗?
相关文章
相关视频
上一篇: phpcms学习总结_PHP教程
下一篇: SAX方式解析XML文件