时间:2021-07-01 10:21:17 帮助过:3人阅读
- php
- $vegetables[0] = "corn";
- $vegetables[1] = "broccoli";
- $vegetables[2] = "zucchini";
- $text = implode(",", $vegetables);
- echo $text;
- ?>
运行结果
corn,broccoli,zucchini
2 PHP字符串转数组 explode()
- php
- $text = "corn, broccoli, zucchini";
- $vegetables = explode(", ", $text);
- print_r($vegetables);
- ?>
运行结果:
- Array
- (
- [0] => corn
- [1] => broccoli
- [2] => zucchini
- )
以上两段代码就是我们向大家介绍的关于PHP数组转字符串和PHP字符串转数组的相关代码。
http://www.bkjia.com/PHPjc/446366.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446366.htmlTechArticle我们今天为大家介绍的 PHP数组转字符串 implode() ? php $vegetables[0]="corn"; $vegetables[1]="broccoli"; $vegetables[2]="zucchini"; $ text = implode (",",$vegetables)...