首页 > 未分类 > php数组转字符串,字符串转数组简单方法
2014
08-07

php数组转字符串,字符串转数组简单方法

php数组转字符串,字符串转数组

<?php
//字符串转数组
 $name='smsyun';
 print_r(str_split($name));
 
 $name2='tanteng,zhangsan,lisi,wangwu';
 print_r(explode(',',$name2));
 
 //数组转字符串
 $name_array=array('tanteng','wang','baidu');
 print_r(implode(',',$name_array));
?>

结果:

Array ( [0] => s [1] => m [2] => s [3] => y [4] => u [5] => n )
 
Array ( [0] => tanteng [1] => zhangsan [2] => lisi [3] => wangwu )
 
tanteng,wang,baidu

友荐云推荐