0

i want to make all array values in one variable

Example:

i have a title

$title = "my name is medo";
$words = explode(' ', $title);

The result is a

$words['0'] = my
$words['1'] = name 
$words['2'] = is 
$words['3'] = medo

i want to make it like that

$allwords = "my,name,is,medo";

thanks all

user2839993
  • 109
  • 2
  • 7

2 Answers2

1

You can use implode:

implode ( "," , $words );
Niels
  • 48,601
  • 4
  • 62
  • 81
0

You can also do this with string functions, which is much easier for your case.

$originalString = "my name is medo";
$finalString = str_replace(" ", ",", $originalString);
wIRELESS
  • 196
  • 3
  • 3