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);   

?>   


运行结果:

Array 

[0] => corn 

[1] => broccoli 

[2] => zucchini 

注: 本函数可安全用于二进制对象。

Copyright © 2014-2024 it689.com (京ICP备12032795号-2) 版权所有 Power by IT689