Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Created May 16, 2013 08:09
Show Gist options
  • Save mikamboo/5590184 to your computer and use it in GitHub Desktop.
Save mikamboo/5590184 to your computer and use it in GitHub Desktop.
Serialisatoin & Désérialisation en PHP d'un tableau dans un fichier.
<?php
//-----------------------------------------------------------
// Serialisatoin & Désérialisation tableau <-> fichier
//-----------------------------------------------------------
echo "<pre>"; print_r($tab_lst_interventions);
$str_dateLog = date('Ymd_His');
$str_cheminLog = CHEMIN_APPLI.'/logs/'.$str_dateLog;
$str_cheminFichier = $str_cheminLog.'/mon_fichiert.txt';
$array_serialized = serialize($tab_lst_interventions);
file_put_contents($str_cheminFichier, print_r($array_serialized, true));
$data = file_get_contents($str_cheminFichier);
echo "<pre> --------------------------- ";
echo "<pre>"; print_r(unserialize($data));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment