PHP数组转字符串与PHP字符串转数组的相关方法解析
我们今天为大家介绍的PHP数组转字符串 implode()
<ol class="dp-xml"> <li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li> <li class=""><span>$vegetables[0] = "corn"; </span></li> <li class="alt"><span>$vegetables[1] = "broccoli"; </span></li> <li class=""><span>$vegetables[2] = "zucchini"; </span></li> <li class="alt"> <span>$</span><span class="attribute"><font color="#ff0000">text</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">implode</font></span><span>(",", $vegetables); </span> </li> <li class=""><span>echo $text; </span></li> <li class="alt"> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span><span></span> </li> </ol>
运行结果
corn,broccoli,zucchini
2 PHP字符串转数组 explode()
<ol class="dp-xml"> <li class="alt"><span><strong><font color="#006699"><span class="tag"></span><span class="tag-name">php</span></font></strong><span> </span></span></li> <li class=""> <span>$</span><span class="attribute"><font color="#ff0000">text</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">"corn, broccoli, zucchini"</font></span><span>; </span> </li> <li class="alt"> <span>$</span><span class="attribute"><font color="#ff0000">vegetables</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">explode</font></span><span>(", ", $text); </span> </li> <li class=""><span>print_r($vegetables); </span></li> <li class="alt"> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li> </ol>
运行结果:
<ol class="dp-xml"> <li class="alt"><span><span>Array </span></span></li> <li class=""><span>( </span></li> <li class="alt"> <span>[0] =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> corn </span> </li> <li class=""> <span>[1] =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> broccoli </span> </li> <li class="alt"> <span>[2] =</span><span class="tag"><strong><font color="#006699">></font></strong></span><span> zucchini </span> </li> <li class=""><span>) </span></li> </ol>
以上两段代码就是我们向大家介绍的关于PHP数组转字符串和PHP字符串转数组的相关代码。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
