note 33876 deleted from ref.array by didou
| From: | didou@php.net | Date: | Thu, 10 Jul 2003 08:10:25 +0000 |
| Subject: | note 33876 deleted from ref.array by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51832@lists.php.net to get a copy of this message | ||
Note Submitter:
----
here are useful functions for submitting a PHP array to a simple text field in mySQL (or other) and
then pulling it back into an array (hash friendly)... at this point, it's only 1
demensional...
function file_2string($array)
{
$vals=array_values($array);
$keys=array_keys($array);
$x=0;
while($x<count($keys))
{
if ($x!=0)
{
$result.="|";
}
$result.=$keys[$x]."=".$vals[$x];
$x++;
}
return $result;
}
function file_2array($string)
{
$elements=explode("|",$string);
foreach ($elements as $element)
{
$temp=explode("=",$element);
$result[($temp[0])]=$temp[1];
}
return $result;
}