http://www.contentparking.com/psl/
//Array2Txt() by Snt (snt@celeb-x.com)
function Array2Txt($array,$fill='',$tab=1,$compress=0) {
if (!$fill) {
$txt_return='array(';
}
$n=rand();
$run[$n]=0;
for($i=0;$i<$tab;$i++) {$t.="\t";}
foreach ($array as $key => $value) {
if (!$run[$n]) {
$c='';
} else {
$c=', ';
}$run[$n]++;
if (is_array($value)) {
$txt_return.=$c."\n".$t.'\''.$key.'\' => array('.Array2Txt($value,'',1,$tab+1);
continue 1;
}
$txt_return.=$c."\n".$t.'\''.$key.'\' => \''.$value.'\'';
}
if (!$fill) {
$txt_return.=');';
} else {
$txt_return.=')';
}
if ($compress) {
return gzcompress($txt_return, 9);
} else {
return $txt_return;
}
}
function Txt2Array($arraytxt,$decompress=0) {
if ($decompress) {
eval('$return_array = '.gzuncompress($arraytxt));
return $return_array;
} else {
eval('$return_array = '.$arraytxt);
return $return_array;
}
}
Store (compressed) PHP arrays in MySQL BLOB or TEXT fields! 🙂
Have Fun!
Snt
keywords:
convert array to text, array into text, array in textformat, textarray, array converter, array text, text array