David T-G wrote:
> 
> Brent --
> 
> The data file format is
> 
>   field@@data
>   field@@data
>   ...
> 
> and a real example is
> 
>   comment@@this is a comment
>   latdir@@N
>   londir@@W
>   latdec@@36
>   londec@@89
>   ...
> 
> and my code [now, after mods,] looks like
> 
>   ...
>   if ( file_exists($filelocation) )                     # do we have an info file?
>   {
>     $newfile = fopen($filelocation,"r");                # grab it and start reading!
>     while ( !feof ($newfile) )                          # (go only until the end, of 
>course)
>     {
>       $commentline = trim(fgets($newfile));             # get one line with 
>whitespace trimmed
>       if ( $commentline )                               # a line with data?
>       {
>         list ($field,$data) = preg_split("/@@/",$commentline);  # split it
>         $content[$field] = preg_replace("/<br>/","\n",$data) ;  # replace our 
>swapped '<br>'s with original '\n's and store it in the hash
>       }
>     }
>     fclose($newfile);                                   # always lock up
>   }
>   ...
> 
> so I'm just using fgets to read it.  The reason it looks that way is
> because, after the user has had the opportunity to edit the fields and
> hits the button, I process the data as
> 
>   ...
>     $newfile = fopen($filelocation,"w");
>     foreach ($keylist as $k)            # loop thru keys
>       { 
>fwrite($newfile,"$k@@".ereg_replace("(\n|\r)+","<br>",stripslashes(${base64_encode($k)}))."\n")
> ; }     # write the clear text out
>     fclose($newfile);
>   ...
> 
> Although I've solved the problem for now, the next version will probably
> end the data with a @@ and so I can just read another line if I don't
> have a closer.

Ignore me if this has already crossed your mind... but why not
use XML? You format would be extensible and there are utilities
that can process the input for you.

Cheers,
Rob.
-- 
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer  |
:----------------------------------------------:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109                 |
:----------------------------------------------:
| Website : http://www.webmotion.com           |
| Fax     : (613) 260-9545                     |
`----------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to