php按照逗号分割字符串
文章描述:
把字符串按指定字符分割成数组,把数组按指定字符拼装成字符串,php分割字符串与数组转字符串
explode
按逗号分割字符串,字符串转数组
$str = "a,b,c,d,e";
$strArray = explode(',',$str);
print_r($strArray);
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e )
implode
把数组元素组合为一个字符串
$arr = array('images/1.jpg','images/2.jpg','images/3.jpg','images/4.jpg');
echo implode(",",$arr);
images/1.jpg,images/2.jpg,images/3.jpg,images/4.jpg
发布时间:2023/08/17
发表评论