数组和字符串相互转化!

把数组元素组合为字符串:数组->字符串

<?php
$arr = array('Hello','World!','I','love','Shanghai!');
echo implode(" ",$arr);
?>

把字符串打散为数组:字符串->数组

<?php
$str = "Hello world. I love Shanghai!";
print_r (explode(",",$str));
?>

 

posted @ 2017-08-21 21:07  帅到要去报警  阅读(236)  评论(0编辑  收藏  举报