Home Backend Development PHP Tutorial 帮忙解决下数组的有关问题!(初学者问.)

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

Jun 13, 2016 pm 01:46 PM
explode gt quot

帮忙解决下数组的问题!(菜鸟问..)
就是说现在一个变量$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 类似的函数吗?

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

What are the differences between Huawei GT3 Pro and GT4?

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Fix: Snipping tool not working in Windows 11

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

How to Fix Can't Connect to App Store Error on iPhone

How to use PHP explode function and solve errors How to use PHP explode function and solve errors Mar 10, 2024 am 09:18 AM

How to use PHP explode function and solve errors

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决

Split and merge strings using the explode and implode functions Split and merge strings using the explode and implode functions Jun 15, 2023 pm 08:42 PM

Split and merge strings using the explode and implode functions

Common errors and solutions when using the explode function in PHP Common errors and solutions when using the explode function in PHP Mar 11, 2024 am 08:33 AM

Common errors and solutions when using the explode function in PHP

Is watch4pro better or gt? Is watch4pro better or gt? Sep 26, 2023 pm 02:45 PM

Is watch4pro better or gt?

See all articles