如何变换数组逗号分隔的单词字符串

如何变换数组逗号分隔的单词字符串

本文介绍了如何变换数组逗号分隔的单词字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My array looks like this:

Array
(
    [0] => lorem
    [1] => ipsum
    [2] => dolor
    [3] => sit
    [4] => amet
)

How to transform this to a string like this with php?

$string = 'lorem, ipsum, dolor, sit, amet';
解决方案
$arr = array ( 0 => "lorem", 1 => "ipsum", 2 => "dolor");

$str = implode (", ", $arr);

这篇关于如何变换数组逗号分隔的单词字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 03:42