Unifix knowledge database - The original one

Dashboard - News - Search - List - About - Admin


arraystore.php

Author:mike - Fri Nov 18 20:00:11 2005

<?

#       arraystore.php - Copyright(c) 2005 by Mikkel C.M.Christensen
#
#       Stores and retrieves arrays of the following format from plaintextfiles:
#       $array =        array(  array ("",""),
#                               array ("",""),
#                               array ("",""));
#
#       The char "|" are used as seperator and can not be in the arrays
#       if present it will simply be removed.


function SaveArray($array,$file)
{
        $fh=fopen("test.arr","w");
        foreach ($array as $value)
        {
                $value=preg_replace(array("/\|/","/\n/"),array("","|n"),$value);
                fputs($fh, $value[0]."||".$value[1]."\n");
        }
        fclose($fh);
}

function LoadArray($file)
{
        $fh=fopen($file,"r");
        while ($dat=fgets($fh))
        {
                $line=explode("||",$dat);
                $line=preg_replace("/\|n/","\n",$line);
                $arr[]=array($line[0],$line[1]);
        }
        fclose($fh);
        return $arr;
}

?>
Copyright(c) Unifix.org 2002-2011


Dashboard - News - Search - List - About - Admin
 
Powered by Mikjaer Consulting Solutions - Hosted by Specialhosting.dk