我想在一个变量
中创建所有数组值示例:
我有一个标题
$title = "my name is medo";
$words = explode(' ', $title);
结果是
$words['0'] = my
$words['1'] = name
$words['2'] = is
$words['3'] = medo
我想这样做
$allwords = "my,name,is,medo";
感谢所有
答案 0 :(得分:1)
您可以使用implode:
implode ( "," , $words );
答案 1 :(得分:0)
您也可以使用字符串函数执行此操作,这对您的案例更容易。
$originalString = "my name is medo";
$finalString = str_replace(" ", ",", $originalString);