Home > Backend Development > PHP Tutorial > How to print the value of comma

How to print the value of comma

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-03-02 09:42:01
Original
980 people have browsed it

I use implode to grab the field value of the checkbox
After inputting it into mysql
The value of the field is assumed to be 1,2,3

But how to make it display the values ​​between commas separately when echo is displayed?
1 2 3

Reply content:

I use implode to grab the field value of the checkbox
After inputting it into mysql
The value of the field is assumed to be 1,2,3

But how to make it display the values ​​between commas separately when echo is displayed?
1 2 3

<code><?php
$string1 = "1,2,3"; 
$array = explode(',',$string1);//以','对$string1进行切割 
echo $array[0]; //1
echo "\n";
echo $array[1]; //2
echo "\n";
echo $array[2]; //3
echo "\n";
$string2 = implode(' ',$array);//以' '对$array进行合并
echo $string2;  //1 2 3
?>
</code>
Copy after login

Hope it helps you

Isn’t it possible to use explode() to split it into arrays and then read them?
If you don’t want to loop the output, you can explode() and then implode() again.

Related labels:
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template