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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

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

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

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

The explode function in PHP is a function used to split a string into an array. It is very common and flexible. In the process of using the explode function, we often encounter some errors and problems. This article will introduce the basic usage of the explode function and provide some methods to solve the error reports. 1. Basic usage of the explode function In PHP, the basic syntax of the explode function is as follows: explode(string$separator,string$stri

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

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

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

Title: Common errors and solutions when using the explode function in PHP In PHP, the explode function is a common function used to split a string into an array. However, some common errors can occur due to improper use or incorrect data format. This article will analyze the problems you may encounter when using the explode function, and provide solutions and specific code examples. Mistake 1: The delimiter parameter is not passed in. When using the explode function, one of the most common mistakes is that the delimiter parameter is not passed in.

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

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

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

In PHP programming, processing strings is a frequently required operation. Among them, splitting and merging strings are two common requirements. In order to perform these operations more conveniently, PHP provides two very practical functions, namely the explode and implode functions. This article will introduce the usage of these two functions, as well as some practical skills. 1. The explode function The explode function is used to split a string according to the specified delimiter and return an array. Its function prototype is as follows: arra

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

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

See all articles