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
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>
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.