Array to String PHP?

Philip Kirkbride picture Philip Kirkbride · Sep 20, 2011 · Viewed 715.1k times · Source

What is the best method for converting a PHP array into a string?
I have the variable $type which is an array of types.

$type = $_POST[type];

I want to store it as a single string in my database with each entry separated by | :

Sports|Festivals|Other

Answer

Niet the Dark Absol picture Niet the Dark Absol · Sep 20, 2011

Use implode

implode("|",$type);