Re: parsing ini files
| From: | Maxim Maletsky | Date: | Tue, 28 Jan 2003 15:20:54 +0000 |
| Subject: | Re: parsing ini files | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133386@lists.php.net to get a copy of this message | ||
there is a bunch of examples to parse the ini files in PHP. You can even
do one on your own:
1. loop every line
2. if format is [**] then this is the key
3. everything till the empty line is a key = value pair
P.S: please, when replying click on "new email" and cut&paste the email
address. If you click "reply-to" and change the "to" and "body" to
your
own so it looks like a new post, some of us still get it as a thread of
the previous one.
--
Maxim Maletsky
maxim@php.net
"Erich C. Beyrent" <erich.beyrent@beyrent.net> wrote... :
> Hey everybody,
>
> I'm new the list and to PHP, so I thought I'd launch right in with a
> question.
>
> I have a file which contains the following syntax:
>
> ; Events listings
> [event]
> month = january
> day = 23
> year = 2003
> venue = some club
> description = this is an event
>
> [event]
> month = january
> day = 12
> year = 2003
> venue = another club
> description = this is another event
>
> Each one of these headers sections represents the start of a new event. So,
> my code does the following:
>
> $EVENTS = parse_ini_file('./data/events', TRUE);
> while($key = key($EVENTS))
> {
> $$key = current($EVENTS); //variable variables
> next($EVENTS);
> }
>
> The problem is that when I try to print the values for $venue, $day, etc, I
> only get the values for the last section encountered. I need a way to get
> the values of all the events - do my section heads need to be unique, or can
> I continue to use the same format in my ini file?
>
> Thanks in advance!
>
> -Erich-
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>