贝伦酱 2009-11-25
我们今天为大家介绍的PHP数组转字符串与PHP字符串转数组的代码将会用到函数implode() 和函数explode() 。其中implode() 函数是用来数组转字符串时用,而explode() 函数则是用来处理字符串转数组的。
PHP数组转字符串 implode()<?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); ?>
运行结果:
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh