Coding, PHP & MySQL

How to insert an array into a Database

Use the implode and explode functions available in PHP. implode takes an array, and will return a string with all the items in a list. Explode takes a list of items in a string, and gives you back an array. You specify the character(s) that are used as the dividers. For example:

$test = Array('one','two','five','seven'); 
foreach($test as $value) echo $value.'
'; $tstring = implode(',' , $test); echo $tstring.'
'; $test2 = explode(',' $tstring); foreach($test2 as $value) echo $value.'

You Might Also Like