Senin, 23 Mei 2016

Cara Menyimpan Data Array ke Database berupa script dan Source Code PHP MYSQL

Array of data you have and you want to store it in a database? This paper is one of the "How to Save Data Array to a Database".

Cara Menyimpan Data Array ke Database berupa script dan Source Code PHP MYSQL


You simply add the function serialize () on the data of your Array. then serialize the results into the database before you save, if you want to call your array data was enough to add function unserialize () on the data you store in a database. The following simple code serialize () and unserialize ().

$data['nama'] = 'Berga';
$data['web'] = 'www.berga-template.blogspot.com';

/* cetak data array */
echo "<pre>";
print_r($data);
echo "</pre>";

/* serialize data lalu simpan kedalam database */
$data_serialize = serialize($data); 
echo $data_serialize;

/* unserilize data dari database */
$data_unserialize = unserialize($data_serialize);
echo "<pre>";
print_r($data_unserialize);
echo "</pre>";

Simple enough right "Way to Store Data Array to Database"?

Tidak ada komentar:

Posting Komentar