-1

lets say i have an array like this:

Array
(
    [0] => first one
    [1] => second
)

Essentially i want to get both of the values and put them into the same value but separated with a comma.

The desired output would be this:

Array
(
    [0] => first one, second
)

I'm not sure what function can achieve this

Matthew Smart
  • 1,301
  • 4
  • 21
  • 37

2 Answers2

2

Use implode function like :

$newArray[] = implode(',' , $array);

see : http://php.net/manual/en/function.implode.php

Fky
  • 2,133
  • 1
  • 15
  • 23
0

Use the PHP implode method, like so:

implode ( ',' , $array )
terrorfall
  • 1,121
  • 3
  • 16
  • 33